Bad error message in GHCi
If
import Test.QuickCheck
prop_eq_reflexive x = x == x
is loaded into GHCi the following can be observed:
*BadErrorMessage> quickCheck prop_eq_reflexive
Top level:
No instance for (Show (IO ()))
arising from use of `print' at Top level
Probable fix: add an instance declaration for (Show (IO ()))
In a 'do' expression: print it
Hugs gives the more understandable error message
BadErrorMessage> quickCheck prop_eq_reflexive
ERROR - Unresolved overloading
*** Type : (Eq a, Show a, Arbitrary a) => IO ()
*** Expression : quickCheck prop_eq_reflexive
:t
in GHCi gives an even more understandable error message:
*BadErrorMessage> :t quickCheck prop_eq_reflexive
<interactive>:1:0:
Ambiguous type variable `a' in the constraints:
`Arbitrary a' arising from use of `quickCheck' at <interactive>:1:0-9
`Eq a' arising from use of `prop_eq_reflexive' at <interactive>:1:11-27
`Show a' arising from use of `quickCheck' at <interactive>:1:0-9
Probable fix: add a type signature that fixes these type variable(s)
(In the introductory FP courses at Chalmers we use Quick``Check from the start, so this error message bites students in the first week.)
Trac metadata
Trac field | Value |
---|---|
Version | 6.4.1 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | GHCi |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | Unknown |
Architecture | Unknown |