This section lists some deviations of SML/NJ from The Definition of Standard ML. Some of these are documented in the SML '97 Conversion Guide. Since MLton does not implement these features, if your program contains any of them it will not compile under MLton. If you discover other deviations of SML/NJ that affect compilation under MLton, please send mail to MLton@research.nj.nec.com.
=
to be rebound by the declaration:
val op = = 13
This is explicitly forbidden on page 5 of the Definition.
val v = #[1,2,3]
val #[x,y,z] = v
datatype foo = Foo of int | Bar of int
val (Foo x | Bar x) = Foo 13
local
declaration.
signature SIG =
sig
type t = int * int
type u = int * int
sharing type t = u
end
These are disallowed by rule 78 of the definition.
withtype
derived form as described by
the Definition. According to page 55 of the Definition, the type
bindings of a withtype
declaration are substituted simultaneously
in the connected datatype. Consider the following program.
type u = real
datatype a =
A of t
| B of u
withtype u = int
and t = u
According to the Definition, it should be expanded to the following.
type u = real
datatype a =
A of u
| B of int
However, SML/NJ expands withtype
bindings sequentially, meaning
that earlier bindings are expanded within later ones. Hence, the
above program is expanded to the following.
type u = real
datatype a =
A of int
| B of int
withtype
specifications in signatures.
where
structure specification that is similar
to a where type
specification. For example:
structure S = struct type t = int end
signature SIG =
sig
structure T : sig type t end
end where T = S
This is equivalent to:
structure S = struct type t = int end
signature SIG =
sig
structure T : sig type t end
end where type T.t = S.t