confusing type error

2014-12-04 Thread Evan Laforge
I recently got a confusing error msg, and reduced it to a small case: f1 :: Monad m => m Bool f1 = f2 0 0 'a' f2 :: Monad m => Int -> Float -> m Bool f2 = undefined From this, it's clear that f2 is being given an extra Char argument it didn't ask for. However, the error msg (ghc 7.8.3) is:

Re: confusing type error

2014-12-04 Thread Richard Eisenberg
This seems straightforwardly to be a bug, to me. HEAD gives the same behavior you report below. Please post on the bug tracker at https://ghc.haskell.org/trac/ghc/newticket Thanks! Richard On Dec 4, 2014, at 1:50 PM, Evan Laforge wrote: > I recently got a confusing error msg, and reduced it t

Re: confusing type error

2014-12-04 Thread Brent Yorgey
Int -> Float -> Char -> Bool *is* in fact a valid type for f2, since ((->) Char) is a Monad. However, I agree the error message is confusing, especially the "expected n, but got n" part. -Brent On Thu, Dec 4, 2014 at 1:50 PM, Evan Laforge wrote: > I recently got a confusing error msg, and redu

Re: confusing type error

2014-12-04 Thread migmit
I don't see a bug here. f2 is perfectly OK, so, let's examine f1 more closely. It tries to get `m Bool` by applying f1 to three arguments: 0, 0, and 'a'. Now, since `f2` has the type `Int -> Float -> n Bool`, where `n` is of kind `* -> *` (and an instance of `Monad` class, but it's not yet the t

Re: confusing type error

2014-12-04 Thread Yuras Shumovich
It seems to be an instance of https://ghc.haskell.org/trac/ghc/ticket/7869 But it is fixed (both in HEAD and 7.8). Probably the fix is partial? On Thu, 2014-12-04 at 14:53 -0500, Richard Eisenberg wrote: > This seems straightforwardly to be a bug, to me. HEAD gives the same behavior > you report

Re: confusing type error

2014-12-04 Thread Evan Laforge
On Thu, Dec 4, 2014 at 12:59 PM, migmit wrote: > It tries to get `m Bool` by applying f1 to three arguments: 0, 0, and 'a'. > Now, since `f2` has the type `Int -> Float -> n Bool`, where `n` is of kind > `* -> *` (and an instance of `Monad` class, but it's not yet the time to look > for instanc

Re: confusing type error

2014-12-05 Thread Richard Eisenberg
The reason I said "That's a bug!" so confidently is because of the "expected n but got n" part. Even if everything else is OK, we need to fix that one bit. And I tend to agree about using heuristics to report better error messages in the presence of instantiating a type variable with (->). I've

Re: confusing type error

2014-12-05 Thread Dr . ÉRDI Gergő
But it says `expected Char -> Bool, got Char -> m Bool', note the `m' type constructor in the second one. So it's not `n' vs. `n'. On Dec 5, 2014 10:50 PM, "Richard Eisenberg" wrote: > The reason I said "That's a bug!" so confidently is because of the > "expected n but got n" part. Even if everyt

Re: confusing type error

2014-12-05 Thread Brent Yorgey
I think Richard is referring to "The function ‘f2’ is applied to three arguments, but its type ‘Int -> Float -> Char -> Bool’ has only three". Note "applied to three ... but ... only three". Here n = three. -Brent On Fri, Dec 5, 2014 at 9:55 AM, Dr. ÉRDI Gergő wrote: > But it says `expec

Re: confusing type error

2014-12-09 Thread Evan Laforge
I was going to ask if I should go ahead and file a bug anyway, but I just noticed commit 09b7943321f89b945d10f8a914f4c2cbf73dff91 seems to fix it. Many thanks to Yuras! On Fri, Dec 5, 2014 at 7:50 AM, Brent Yorgey wrote: > I think Richard is referring to "The function ‘f2’ is applied to three >