Add `Control.exception.evaluate` equivalent
Opened this issue · 1 comments
codygman commented
I'm moving our codebase to use annotated-exceptions and we have the following:
expectError :: a -> Test.Expectation
expectError = flip Hspec.shouldThrow Hspec.anyErrorCall . Exception.evaluate
I'm just starting to understand annotated-exception
, so not quite sure how to make this work yet.
I think if evaluate
existed my migration path could just be changing the import though.
If so, I think this would be useful for the library since other users likely find themselves in similar situations.
parsonsmatt commented
Seems reasonable! I think a first pass implementation would be like
evaluate :: (NFData a, HasCallStack, MonadIO m) => a -> m a
evaluate a = withFrozenCallStack checkpointCallStack $ liftIO $ Control.Exception.evaluate a
if you want to bake that in, or make a PR