annotated-exception
annotated-exception copied to clipboard
Add `Control.exception.evaluate` equivalent
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.
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