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

Catch readFile exceptions on the repl #184

Merged
merged 2 commits into from
Apr 24, 2018
Merged

Catch readFile exceptions on the repl #184

merged 2 commits into from
Apr 24, 2018

Conversation

thumphries
Copy link
Member

Exceptions thrown by readDeclaration make it impossible to write properties inside GHCi. This PR just catches them.

I think this sufficiently addresses #105, the @chris-martin example from that issue now works.

λ> import Hedgehog
λ> import qualified Hedgehog.Gen as Gen
λ> import qualified Hedgehog.Range as Range
λ> check $ property $ forAll (Gen.integral $ Range.exponential 1 1024) >>= \x -> x + 1 === x
  ✗ <interactive> failed after 1 test.
  
    forAll0 =
      1
    
    This failure can be reproduced by running:
    > recheck (Size 0) (Seed 7634626840477011566 (-6948853007075827919)) <property>
  
False

decls <- findDeclarations path <$> liftIO (readFile path)
pure .
mfile <- liftIO $ readFileSafe path
pure . join . for mfile $ \file ->
Copy link
Member Author

Choose a reason for hiding this comment

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

I dunno if this is actually clearer than MaybeT

Copy link
Member

@jacobstanley jacobstanley left a comment

Choose a reason for hiding this comment

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

:electron:

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 this pull request may close these issues.

None yet

3 participants