I am writing an application where I want to define many types in the withtype clause of a datatype declaration. The following code snippet demonstrates it:
datatype ta = A
withtype tb = int
and tc = tb
mlton fails to compile this code, although smlnj succeeds.
$ mlton -stop o test.sml
Error: test.sml 3.15.
Undefined type tb.
compilation aborted: parseAndElaborate reported errors
I am using mlton-20100608 and smlnj-110.71.
Is this a bug in mlton?
I do not know how to proceed without this sort of declaration: a set of mutually recursive datatypes and types.
The idea comes from the abstract syntax tree types proposed by Andrew Appel for the Tiger language in his book Modern Compiler Implementation in ML, page 98, in file absyn.sml