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

Open
MarcCoquand opened this Issue Mar 21, 2019 · 2 comments

Comments

Projects
None yet
3 participants
@MarcCoquand
Copy link

MarcCoquand commented Mar 21, 2019

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Owner

nick8325 commented Mar 23, 2019

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
You can’t perform that action at this time.