Consider the following Haskell code
module TypeErrors where
f xs = [True | _ <- repeat 0]
x = (x, x)
The Glasgow Haskell Compiler (version 7.8.4) gives three type errors. The second and third arise from the infinite type implied by line 3. The first is
TypeErrors.hs:2:32:
No instance for (Num t0) arising from the literal ‘0’
The type variable ‘t0’ is ambiguous
After commenting out line 3, the module compiles as expected. I'd like to understand better how GHC performs its miracles. So my question is:
Why does GHC object to line 2 if and only if line 3 is present?
Looks like a bug to me. I can confirm the behavior you describe appears in 7.8.4, but does not in 7.10.3, 8.0.2, 8.2.2, or 8.4.2, all of which have either zero or two errors, not zero or three.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With