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

Bug: QuickCheck output doesn't give types to polymorphic terms #64

Open
isovector opened this issue Aug 13, 2020 · 2 comments · Fixed by #65
Open

Bug: QuickCheck output doesn't give types to polymorphic terms #64

isovector opened this issue Aug 13, 2020 · 2 comments · Fixed by #65

Comments

@isovector
Copy link
Contributor

Consider the following signature:

quickSpec $ signature
  [ con "zero" $ liftC @(Num A) $ zero @A
  , con "0" $ liftC @(Num A) $ (0 :: A)
  , instanceOf @(Num Int)
  , withPrintStyle ForQuickCheck
  ]

which produces the following output:

quickspec_laws :: [(String, Property)]
quickspec_laws =
  [ ( "zero = 0" , property $ zero =~= 0)
  ]  

But uh oh! This code is ambiguous in a!

I think the solution is to give an explicit type to any term that isn't applied to a quantified variable (variables always get types when bound in the lambda.)

@isovector
Copy link
Contributor Author

This is actually quite a blocker on my book; I'll see about implementing a solution today, but would love any insight you might have here, Nick!

@nick8325
Copy link
Owner

Reopening, because this is also an issue when printing equations in "normal" mode.

I think if we want to solve this in all cases, we have to take the generated equation (without type annotations) and do type inference on it. Then add extra type annotations so that the inferred type matches up with the actual type of the discovered law.

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.

2 participants