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

Arbitrary instances for exceptions? #41

Open
kindaro opened this issue Aug 16, 2019 · 1 comment
Open

Arbitrary instances for exceptions? #41

kindaro opened this issue Aug 16, 2019 · 1 comment

Comments

@kindaro
Copy link

kindaro commented Aug 16, 2019

Arbitrary instances for exceptions are trivial but tedious to define. Someone has already done the work in text-show package tests, why do we not publish this so that it is reusable?

It would be useful when checking code that manages exception handling. IO code may be mocked in Catch monad and tested for exception resilience. I am actually doing this somewhere even now.

@kindaro
Copy link
Author

kindaro commented Aug 20, 2019

Actually the code at the link is not fit for use cases where arbitrary :: Gen SomeException should generate all kinds of exceptions. At that link, it is defined thusly:

instance Arbitrary SomeException where
    arbitrary = SomeException <$> (arbitrary :: Gen AssertionFailed)

— So it will only ever generate failed assertions. The more reason to create a more "varied" generator!

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

No branches or pull requests

1 participant