Is there a particular reason that the transformers version of the MaybeT monad does not have a MonadFix instance?
It seems like the following instance would be suitable:
instance (MonadFix m) => MonadFix (MaybeT m) where
mfix f = MaybeT $ mfix $ \a -> runMaybeT $ f $ case a of
Just a -> a
Nothing -> error "mfix MaybeT: Nothing"
I don't think it's possible to hit the error case:
In order to terminate f cannot be strict so it must return a value without evaluating its input. If f returns a Nothing, then you have your return value and you're done. If f returns a Just, then we don't hit the error case.
- Job