type checking fails with a correct type

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Thu Apr 30 10:20:44 EDT 2009

On Apr 30, 2009, at 09:52 , Jan Jakubuv wrote:
>    *Main> :t nonsense
>    nonsense :: (SUBST s) => t -> Maybe s
> But, when I put this signature into the code (that is, when the  
> commented
> line above is uncommented) then type checking fails with the following
> error:
>    Ambiguous type variable `s' in the constraint:
>      `SUBST s'


The type really is ambiguous according to GHC's rules, because you're  
missing some relationships.  As I understand it (which may well be  
wrong), f you leave off the explicit typing it will successfully infer  
everything including the missing relationship; but if you explicitly  
type it you prevent inference of the missing relationship.

brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20090430/ce803a23/PGP.bin

More information about the Glasgow-haskell-users mailing list