[MLton] Few problems with porting...

Matthew Fluet fluet@cs.cornell.edu
Sun, 16 Nov 2003 06:54:53 -0500 (EST)


> I just read this section of the user's guide. I also found something else
> in SML/NJ 110.0.7 - not sure if it's a bug which has been fixed by now:
>
> datatype List = list
>
> val a = nil : 'a List
>
> fails to type check.
> 
> So datatype replication does not seem to work properly in SML/NJ.

The behavior of SML/NJ is correct in that case.  Note that

datatype List = list

creates a datatype (List), of arity 0, with one constructor (list), of
arity 0.  Hence, the type constraint

val a = nil : 'a List

is incorrect on two accounts: it gives the List type constructor
an argument and nil is not a member of the List datatype.

Datatype replication requires the datatype keyword:

datatype List = datatype list

-Matthew