[MLton] List comprehensions?

Andreas Rossberg AndreasRossberg at web.de
Fri Jun 1 11:41:36 PDT 2007


From: "Wesley W. Terpstra" <wesley at terpstra.ca>
>
> I've finally understood what 'first-class' modules are.
>
> Is there any good reason to support these? I can't really think of a  good 
> use of them except as a way to mimic OOP.

Among other things, they give you first-class polymorphism and existential 
types. Lots of interesting and weird things you can do with those... :-)

> I'm also still trying to understand what these higher-order functors 
> would be good for and what they do.

Well, generally speaking, they give you the same general abstraction 
facility on the module level, that functional programmers wouldn't want to 
miss on the term level. Granted, you will only rarely need this. But if you 
look at the C++ template library, there actually are some uses of similar 
constructions (which in C++ materialise as so-called template template 
arguments).

And from the point of view of language design, they make the module system 
much more uniform.

> TBH, I agree with skaller in that  I'm not a fan of functors in the first 
> place. Most of the places I've  (needed to) use them, type classes would 
> have been a better fit. Type  classes in haskell already support something 
> very 'functor' like: you  can make a type class that depends on other type 
> classes. For  example, an Array can be compared if its elements can be.

Of course, we want to have a unified concept of both. Currently, modules and 
type classes represent different points in the design space, trading off 
expressiveness vs convenience differently. I want my cake and eat it too. 
Moreover, a common sentiment on the ML side of the fence is that a clean 
theory of type classes requires a clean theory of modules.

- Andreas




More information about the MLton mailing list