Closed jwiegley closed 9 years ago
The main Proxy
type implements MonadError
and the catchError
method for that is the same as the catchP
you wrote.
I also think try
could be written in terms of catchError
in a way that is Proxy
-independent:
try :: MonadError e m => m a -> m (Either e a)
try m = fmap Right m `catchError` (\e -> return (Left e))
Ah, excellent, I like that solution much more.
These allow for more direct handling of exceptions raised in Proxies, similar to
tryC
andcatchC
found in conduit. I'm not sure theMonadSafe
constraint is even necessary, it work fine with justMonadCatch
, but I have a feeling you would have a deeper insight into this, @Gabriel439.