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

[#100] Add bug #103

Merged
merged 2 commits into from
Dec 22, 2017
Merged

[#100] Add bug #103

merged 2 commits into from
Dec 22, 2017

Conversation

vrom911
Copy link
Contributor

@vrom911 vrom911 commented Dec 21, 2017

Resolves #100

Copy link
Contributor

@chshersh chshersh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

-- | Generate a pure value which, when forced, will synchronously
-- throw the exception wrapped into 'Bug' data type.
bug :: (HasCallStack, Exception e) => e -> a
bug e = Safe.impureThrow (Bug (Safe.toException e) ?callStack)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this note in base docs:

image

Instead of ?callStack, we should use the callStack function from GHC.Stack.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then the ImplicitParams extension can be removed.

data Bug = Bug SomeException CallStack
deriving (Show)

instance Exception Bug
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have a proper displayException implementation here. We should use the prettyCallStack function from GHC.Stack to render the call stack, displayException to render the stored SomeException, and concatenate the two using with "\n" in between (SomeException comes first, then "\n", then pretty-printed CallStack).

This would match the behavior of error.

@vrom911 vrom911 merged commit ed9c424 into master Dec 22, 2017
@vrom911 vrom911 deleted the vrom911/100-bug branch December 22, 2017 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants