Closed akrmn closed 2 years ago
hi @ekmett @hvr I'd really appreciate getting some feedback on this, who would be the right person for that? thanks!
A couple of thoughts:
I have no real objection to adding something with this functionality.
However, the name doesn’t quite follow mtl/transformer conventions where lifts are used in a stylized manner to raise operations from lower monads in the stack (and are supplied by transformers rather than mtl).
I have no real objection to adding something with this functionality.
thanks!
However, the name doesn’t quite follow mtl/transformer conventions where lifts are used in a stylized manner to raise operations from lower monads in the stack (and are supplied by transformers rather than mtl).
I think this would have to be defined in mtl
, though, since the type has to mention MonadError
, which is defined here. Regarding the name, I absolutely agree, naming things is hard indeed. Perhaps
exceptToError
by analogy with exceptToMaybeT
(though the Error
suffix doesn't quite convey that the return value is m a
for any MonadError _ m
)?
exceptToMonadError
like above, but makes a bit clearer what it does (though I don't think I've ever seen the word Monad
in a function name)
withError'
by analogy with withError
, the '
indicating that the error type can change?
rethrow
could also work, there's no analogy with existing functions but the name is memorable and perhaps what users would try to look for.
rethrowExceptT
like above, but indicating the input type
I really don't have a strong opinion regarding the name, so I'll be happy to have any other suggestions
@akrmn I like this functionality. Can I suggest modifyError
or translateError
(or some variation thereof)? Then you have the intuition withError = modifyError (f :: e -> e)
.
Can this be renamed to modifyError
? Naming is really the only thing keeping it unmerged.
@emilypi @chessai thanks for the suggestion, I'll rename it to modifyError
.
Needs a resolution and a changelog entry and we're good
hey @emilypi thanks for taking this forward
I've just added the changelog entry, sorry I forgot to do it earlier
Thanks for bearing with us @akrmn and thanks for the PR :)
I recently came to this as a handy way to adapt a function from one
MonadError
to another. I couldn't find anything with this signature on hoogle, so I thought I'd add it here. I'm not 100% sure about the name, so any suggestions are welcome. I hope the docs are clear enough.