[MLton] List comprehensions?

Andreas Rossberg AndreasRossberg at web.de
Thu May 31 09:42:15 PDT 2007


Wesley W. Terpstra wrote:
> I didn't really understand the 'first-class modules' or 'higher-order
> functor' additions.
>
> This feature will probably break MLton's defunctorization, though:
> > * Local Modules.
> >
> >   Structure, functor and signature declarations are allowed in
> > local scope:
> >
> >     fun sortWithoutDups compare =
> >         let
> >           structure Set = MkSet(type t = string; val compare =
> > compare)
> >         in
> >           Set.toList o foldr Set.insert Set.empty
> >         end
> I have needed this feature in the past, but what does this mean for
> 'val's declared in the functor? Must they be evaluated every time the
> function is called? I think so. They might depend on the parameter.

Yes. Operationally, a functor application isn't much different from a  
function application, so it's body has to be evaluated each time the  
application is performed. But AFAICS, this should not break  
defunctorisation - you simply defunctorise locally.

What most likely does break defunctorisation, though, is the  
combination of first-class and higher-order modules.

- Andreas




More information about the MLton mailing list