[MLton] A little exercise for the type checker:

Stephen Weeks MLton@mlton.org
Thu, 12 Feb 2004 14:25:28 -0800


> fun pair x y = fn z => z x y;
> fun run z = 
> let val x1 = fn y => pair y y in
>   let val x2 = fn y => x1(x1(y)) in
>     let val x3 = fn y => x2(x2(y)) in
>       let val x4 = fn y => x3(x3(y)) in
>         x4(z)
>       end
>     end
>   end
> end
> 
> annah$ mlton -show-basis true test.sml | wc -l
>      327
> 
> Scary!

Not to worry.  The pretty-printed type for "run" is large, but
internally we use unification and hash consing, so the internal
representation is small.