> 
> This is a distilled version of a problem that arose in a student's program:
> 
> > f :: a -> a
> > f x = g
> >    where
> >    g :: a
> >    g = x
> 
> Reading file "[...]":
> Type checking
> ERROR "[...]" (line 5): Inferred type is not general enough
> *** Expression    : g
> *** Expected type : a
> *** Inferred type : _2
> 

> Is there a simple explanation for this phenomenon?

The scope of the type variable in the first type declaration 
doesn't include the function definition, so the g :: a is 
saying that g has to have type all t. t.

Wasn't there once some discussion of the question of making 
variables in type declarations for functions range over the 
body?
-- 
J�n Fairbairn                                 [EMAIL PROTECTED]
18 Kimberley Road                                        [EMAIL PROTECTED]
Cambridge CB4 1HH                      +44 1223 570179 (pm only, please)


Reply via email to