[Haskellcafe] Monad transformer responsibilities
Claus Reinke
claus.reinke at talk21.com
Fri Jun 5 09:02:15 EDT 2009
 bar :: (C T) => T
 *Main> :t bar

 <interactive>:1:0:
 No instance for (C T)
 arising from a use of `bar' at <interactive>:1:02
 Possible fix: add an instance declaration for (C T)
 In the expression: bar
I'm not sure where that comes from, but it does seem to be an
artifact of GHC's type inference, which seems unwilling to infer
a flexible context even if flexible contexts are enabled:
*Main> :show languages
active language flags:
XImplicitPrelude
XFlexibleContexts
*Main> let f _ = negate []
*Main> :t f
f :: (Num [a]) => t > [a]
*Main> let f _ = negate [()]
<interactive>:1:10:
No instance for (Num [()])
arising from a use of `negate' at <interactive>:1:1020
Possible fix: add an instance declaration for (Num [()])
In the expression: negate [()]
In the definition of `f': f _ = negate [()]
*Main> let f :: Num [()] => t > [()]; f _ = negate [()]
*Main> :t f
<interactive>:1:0:
No instance for (Num [()])
arising from a use of `f' at <interactive>:1:0
Possible fix: add an instance declaration for (Num [()])
In the expression: f
This does look like a bug to me? Compare with Hugs (Hugs mode):
Main> :t let f _ = negate [] in f
let {...} in f :: Num [a] => b > [a]
Main> :t let f _ = negate [()] in f
let {...} in f :: Num [()] => a > [()]
Claus
More information about the HaskellCafe
mailing list