[MLton] Bug in signature ascription

Wesley W. Terpstra terpstra at gkec.tu-darmstadt.de
Tue Feb 6 14:28:28 PST 2007

On Feb 6, 2007, at 10:38 PM, Matthew Fluet wrote:
> I don't believe that there is any bug in signature ascription.  You  
> are simply encountering the fact that FOLD is not the principal  
> signature of Fold.  If you eagerly ascribe the signature FOLD to  
> Fold, then the resulting types are too constrained to give Foldr  
> the signature FOLD. (There may be a different implementation of  
> Foldr in terms of Fold:FOLD that can ascribe Foldr the signature  
> FOLD.)
> You can "fix" things like this:
> local
>   structure Fold = struct ... end
>   structure Foldr = struct ... end
> in
>   structure Fold :> FOLD = Fold
>   structure Foldr :> FOLD = Foldr
> end

Let me confirm that I understand what you're saying: Foldr needs  
enough polymorphism to match the signature FOLD. Unfortunately, the  
implementation of Foldr required more polymorphism from Fold than  
FOLD let escape. That's quite a nasty corner case, and I would've  
never suspected it. Thanks! I just assumed that Vesa's signature was  
correct since the whole Fold structure is deep magic that I'm  
terrified to touch. :-)

In fact, I've already found that Foldr.t needs five type variables,  
or it breaks variable arity polymorphism. So, I guess the wiki page  
which describes the signature is wrong. I'll correct the page as soon  
as I've found the polymorphism that Fold lost.

Is there any way to get a printout of the principle signature? One  
that doesn't have '???' all over it?

More information about the MLton mailing list