parsonsmatt/annotated-exception

handleJust, catchJust

Opened this issue · 1 comments

This package doesn't include handleJust and catchJust functions - Is there some reason they are difficult to implement here, or just not something gotten around to yet?

I haven't looked at them yet.

catchJust :: HAS_CALL_STACK => (C.MonadCatch m, Exception e) => (e -> Maybe b) -> m a -> (b -> m a) -> m a
catchJust f a b = withFrozenCallStack catch a (\e -> maybe (throwM e) b $ f e)

This feels like it should "just work" - maybe throwM being replaced with throwWithoutAnnotations or whatever I named that function, since catch will re-attach annotations to rethrown exceptions