Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple example in ghci passes when it shouldn't #249

Closed
MarcCoquand opened this issue Mar 21, 2019 · 2 comments · Fixed by #375
Closed

Simple example in ghci passes when it shouldn't #249

MarcCoquand opened this issue Mar 21, 2019 · 2 comments · Fixed by #375

Comments

@MarcCoquand
Copy link

If we run

Prelude Test.QuickCheck> quickCheck (\xs -> reverse xs == xs)
+++ OK, passed 100 tests.

It passes and it's ambiguous why it does that (and it shouldn't)

@phadej
Copy link
Contributor

phadej commented Mar 21, 2019

because GHCi defaults to ()

λ Test.QuickCheck> quickCheck (\xs -> reverse xs == xs)
+++ OK, passed 100 tests.
λ Test.QuickCheck> quickCheck (\xs -> reverse xs == (xs :: [()]))
+++ OK, passed 100 tests.
λ Test.QuickCheck> quickCheck (\xs -> reverse xs == (xs :: [Int]))
*** Failed! Falsifiable (after 5 tests and 2 shrinks):    
[0,1]
λ Test.QuickCheck> :set -XNoExtendedDefaultRules 
λ Test.QuickCheck> quickCheck (\xs -> reverse xs == xs)

<interactive>:9:1: error:
    • Ambiguous type variable ‘a0’ arising from a use of ‘quickCheck’

Read more in the GHC manual: https://downloads.haskell.org/~ghc/8.4.4/docs/html/users_guide/ghci.html#type-defaulting-in-ghci

@nick8325
Copy link
Owner

Yes, this is due to GHCi defaulting all type variables to (). Annoying, but I don't think there's anything we can do about it.

Would it be worth warning about this in the documentation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants