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

Felipe Lessa felipe.lessa at gmail.com
Mon Jun 22 20:25:59 EDT 2009

On Tue, Jun 23, 2009 at 02:02:25AM +0200, Eric wrote:
> It seems that an extension is required:
>     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?

Simple: the definition of MonadState uses those extensions.

If the library was part of your code you would have had to turn
on some extensions, but you could have used them only on some
files (e.g. using LANGUAGE pragma).  Here the same thing is
happening, but the library is not part of your code.  Errr, not a
great explanation, but I HTH anyway. :)


More information about the Haskell-Cafe mailing list