Zulip Chat Archive

Stream: lean4

Topic: Reverse of MonadExcept.ofExcept


Adam Topaz (Apr 15 2025 at 11:58):

MonadExcept.ofExcept converts e : ExceptT E m X to m X given MonadExcept E m. For some reason I need the reverse of this:

def foo [Monad m] [MonadExcept ε m] (e : m α) : ExceptT ε m α := .mk do
  try let a  e ; return .ok a
  catch e => return .error e

Do we have such a function somewhere? I couldn't find it.

Markus Himmel (Apr 15 2025 at 12:00):

Not 100% sure, but possibly docs#observing

Adam Topaz (Apr 15 2025 at 12:01):

I guess it's docs#ExceptT.mk composed with that, yes.


Last updated: May 02 2025 at 03:31 UTC