[MLton] funny error message

Wesley W. Terpstra wesley@terpstra.ca
Fri, 23 Sep 2005 14:01:50 +0200


On Sep 23, 2005, at 10:59 AM, Andreas Rossberg wrote
> Henry Cejtin wrote:
>> I am trying to convert some old SML (1990) code to SML 1997, and  
>> MLton is
>> printing the following error out:
>>     Variable type in structure disagrees with signature.
>>     variable: flatten
>>     structure: ['a] stream stream -> ['a] stream
>>     signature: ['b] stream stream -> ['b] stream
>> As near as I can tell, 'a and 'b are both free.  Am I confused or  
>> is this
>> error message bad?

I've had an error message like this once.
It happened when something was redefined in the same scope:

type unit = int
signature X = sig val x: unit end
structure Y :> X = struct val x = () end

> This is most likely caused by the value restriction, which wasn't  
> yet present in today's form in SML 90. That is, the definition of  
> `flatten' in the structure is no longer polymorphic according to  
> the new rules. Usually, eta-expansion is sufficient to work around  
> this (it is likely that the old code implements `flatten' by  
> partial application of something like fold - just turn it into a  
> fun declaration).

MLton usually gives me an error about being unable to locally
determine the type when that's the problem. Or else something
about being unable to generalize the type. So, if that turns out
to be the case, I think it is a MLton bug...

Btw, why does this compile?

fun id2 x y = y
signature X = sig val y: 'a -> 'a end
structure Y = struct val y = id2 "x" val z = y 5 end