JT <jt@[EMAIL PROTECTED]
> writes:
> Chris Reade escreveu:
>> fun f1 (x,y,z) = (x,y,1)
>> fun f2 (x,y,z) = (x,y,z * x)
>> fun f3 (x, y,z) = (x + 1, y, z)
>> val body = f3 o f2
> Upon evaluating this, an error crops up.
>
> - val body = f3 o f2;
> stdIn:5.5-5.19 Warning: type vars not generalized because of
> value restriction are instantiated to dummy types (X1,X2,...)
> val body = fn : int * ?.X1 * int -> int * ?.X1 * int
>
> This must have something to do with the newer SML 97 standard.
It does indeed. SML 97 restricts non-values in val bindings to
monomorphic to avoid problems with polymorphic references. Since the
expression f3 o f2 is not a value, it is not generalized (made
polymorphic). To get around the problem, you can eta-expand the
expression:
val body = fn arg => (f3 o f2) arg
which reduces to
val body = fn arg => f3 (f2 arg)
or, even simpler,
fun body arg = f3 (f2 arg)
Torben


|