[Haskell-cafe] Type Error. Why!?
robdockins at fastmail.fm
Tue Nov 21 16:07:28 EST 2006
On Nov 21, 2006, at 2:24 PM, Tim Newsham wrote:
> Can anyone tell me why I get a type error in the following code?
> I have to define liftA2 twice to avoid the type error. Both
> times its defined identically but with different type signature.
> If I use the original liftA2 in place of liftA2' I get:
> Ambiguous type variable `a' in the constraint:
> `Arrow a' arising from use of `>>>' at whyerror.lhs:36:25-27
> Possible cause: the monomorphism restriction applied to the
> liftA2' :: forall b a1 b1 c. (a1 -> b1 -> c) -> a b a1 -> a b
> b1 -> a b c
> (bound at whyerror.lhs:36:1)
> unsplit' :: forall a1 b c. (a1 -> b -> c) -> a (a1, b) c
> (bound at whyerror.lhs:34:1)
> split' :: forall b. a b (b, b) (bound at whyerror.lhs:33:1)
> Probable fix: give these definition(s) an explicit type signature
> or use -fno-monomorphism-restriction
I'm not sure I understand your problem. If I comment out split',
unsplit' and liftA2', your program compiles and executes.
Without signatures, MR kicks in and gives the error above (which
recommends you give signatures ;-) ) However, you've got type
signatures, and the foul MR beast is slain, so the problem appears
> Tim Newsham
Speak softly and drive a Sherman tank.
Laugh hard; it's a long way to the bank.
More information about the Haskell-Cafe