annotated-exception icon indicating copy to clipboard operation
annotated-exception copied to clipboard

handleJust, catchJust

Open chris-martin opened this issue 2 years ago • 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?

chris-martin avatar Nov 30 '23 17:11 chris-martin

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

parsonsmatt avatar Nov 30 '23 17:11 parsonsmatt