[Haskell-cafe] GHCi infers a type but refuses it as type signature

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Tue Jun 23 20:33:26 EDT 2009

On Jun 22, 2009, at 20:02 , Eric wrote:
>    Non type-variable argument in the constraint: MonadState [a] m
>    (Use -XFlexibleContexts to permit this)
>    In the type signature for `play3':
>      play3 :: (MonadState [a] m, Eq a) => a -> m Bool
> So how is it possible that GHCi can infer (and use) a type that you
> cannot use as signature?

This is an infelicity in the GHC type checker:  if a library uses an  
extension, inferred types involving things in the library will  
silently use the extension even though you haven't declared it --- but  
if you try to specify the type manually, you have to explicitly  
declare the extension.  I think there's a bug report open on it,  
because it's poor form (not to mention confusing).

I think this is the right bug.

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/haskell-cafe/attachments/20090623/94514d28/PGP.bin

More information about the Haskell-Cafe mailing list