-
Notifications
You must be signed in to change notification settings - Fork 120
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
Add HasCallStack where error can occur #235
Conversation
When this fails due to an empty list there's no stack trace pointing to the bad "elements" call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requires more work for backwards compatibility. However, I think the error message is clear enough even without accurate source locations, so for me personally closing this as won't fix would be ok too.
EDIT: To be clear, I'm not a maintainer. This is just a third party comment.
@@ -197,7 +198,7 @@ frequency xs0 = choose (1, tot) >>= (`pick` xs0) | |||
pick _ _ = error "QuickCheck.pick used with empty list" | |||
|
|||
-- | Generates one of the given values. The input list must be non-empty. | |||
elements :: [a] -> Gen a | |||
elements :: HasCallStack => [a] -> Gen a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only works with recent versions of GHC.
My call-stack
package provides a shim for backwards compatibility. @nick8325 are you fine with adding that dependency? If yes, we could also add source locations to e.g. ===
.
If not, we would want to CPP the HasCallStack =>
of the type signature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nick8325 even with this change this will still require GHC 7.4.*.
@sol The error message is certainly clear, but it's not useful for debugging if |
When this fails due to an empty list there's no stack trace pointing to the bad "elements" call.