transformers: remove instance MonadFix ExceptT and ErrorT

Bertram Felgenhauer bertram.felgenhauer at googlemail.com
Tue Aug 12 15:10:12 UTC 2014


Henning Thielemann wrote:
> I propose to remove the MonadFix instance for the ExceptT transformer,
> because it gives the illusion that it can handle exceptions, which it
> cannot.

I think this analysis is not quite correct. The exception is not handled
but propagated outside the mfix, which is what I would expect:

  ghci> runExcept (mfix (\_ -> throwE ()))
  Left ()

The only case where one gets to see the artificial bottom introduced
in the exception case, is when one incorporates the fixpoint value into
an exception:

  ghci> runExcept (mfix (\v -> throwE v))
  Left *** Exception: mfix ExceptT: Left

That looks reasonable to me, because indeed no value is being produced
by the inner monad action. Note that 'mfix' is a partial function to
begin with; one always has to be careful about using the produced value
inside the argument of 'mfix'.

-1 from me on the proposal.

Cheers,

Bertram


More information about the Libraries mailing list