[MLton] HOL's Moscow ML implementation, and pushing MLton to emulate it

Daniel C. Wang danwang@CS.Princeton.EDU
Fri, 08 Apr 2005 19:10:01 -0400


Woops typo.. should be the code below..

structure List =
   struct
     datatype ('a,'b) listF =
       Nil
     | Cons of ('a * 'b)

     fun length wrap Nil =  0
       | length wrap (Cons(_,b)) = 1 + length wrap (wrap b)

     fun wrapIntList [] = Nil
       | wrapIntList ((x:int)::xs) = Cons(x,xs)

     fun wrapRealList [] = Nil
       | wrapRealList ((x:real)::xs) = Cons(x,xs)

     val v1 = length wrapIntList (wrapIntList [1,2,3,4])
     val v2 = length wrapRealList (wrapRealList [1.0,2.0,3.0,4.0])

   end