Closed aherrmann closed 6 years ago
Is a tag meaningful and useful?
Yes, because just as state and reader compose with lenses, exceptions compose with prisms.
So that if you have a bunch of your program which can throw (and presumably catch
) PuddingException
-s and another bit throws PoundCakeException
-s, then you can implement that as one
Either CakeException
data CakeException = Pudding PuddingException | PoundCake PoundCakeException
I'm not sure how to best do the interaction with IO
, however. Maybe by making a special type of exception TaggedException tag e
which is a newtype for e
?
Should we follow Control.Monad.Catch and have separate capabilities for throw/catch/mask, or rather one class for all?
I have no opinion on this one.
Should the error type be an index to HasError
Yes.
The general IO case could be covered with a synonym HasError_ where e ~ SomeException.
Well, you can also implement HasError tag AnotherExceptionType
with IO
.
As requested in https://github.com/tweag/capabilities-via/pull/17#discussion_r209926973 .
Some points for discussion:
Is a tag meaningful and useful? It could be used to select a layer in a transformer stack. E.g.
Control.Monad.Catch
and have separate capabilities for throw/catch/mask, or rather one class for all? Separate classes seem more flexible. E.g. throw works in cases where mask doesn't.HasError
? IfHasError
should cover e.g.ExceptT
then, it seems, the answer should be yes. The generalIO
case could be covered with a synonymHasError_
wheree ~ SomeException.
cc @aspiwack