The reason there's an error message at all is because of the
monomorphism restriction.  So that's not surprising.

So the compiler has to solve the constraints { Num (f a), Functor f }
in the absence of any other context whatsoever.  

So the constraint (Functor f) is certainly ambiguous, in the sense that
there are many different instantiations of 'f' that could resolve it.

Can you suggest a better error message?  I'm always looking for ways to
report errors more informatively.

Simon

| -----Original Message-----
| From: Martin Sulzmann [mailto:[EMAIL PROTECTED]]
| Sent: 25 November 2002 10:04
| To: [EMAIL PROTECTED]
| Subject: incorrect type error message
| 
| Consider
| 
| module Bug where
| 
| e = fmap id 1
| 
| ghci --version
| The Glorious Glasgow Haskell Compilation System, version 5.02.2
| 
| says
| 
| :l Bug.hs
| Compiling Bug              ( Bug.hs, interpreted )
| 
| Bug.hs:5:
|     No instance for (Num (f a))
|     arising from the literal `1' at Bug.hs:5
|     In the second argument of `fmap', namely `1'
|     In the definition of `e': fmap id 1
| 
| Bug.hs:5:
|     Ambiguous type variable(s) `f' in the constraint `Functor f'
|     arising from use of `fmap' at Bug.hs:5
|     In the definition of `e': fmap id 1
| 
| although
| 
| :t (fmap id 1)
| forall f a. (Num (f a), Functor f) => f a
| 
| Clearly, 'f' is not ambiguous.
| 
| Martin
| 
| 
| _______________________________________________
| Glasgow-haskell-bugs mailing list
| [EMAIL PROTECTED]
| http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
_______________________________________________
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to