Note: This follows how MonadFix works for every Monad involving a sum type currently.
instance MonadFix Maybe where
    mfix f = let a = f (unJust a) in a
             where unJust (Just x) = x
                   unJust Nothing  = error "mfix Maybe: Nothing"

instance
MonadFix (Either e) where mfix f = let a = f (unRight a) in a where unRight (Right x) = x unRight (Left _) = error "mfix Either: Left"

so it seems the logical extension of your request would be to strip all such instances, which seems to me to speak to you having a different interpretation of the purpose of mfix than its original authors.

-Edward


On Tue, Aug 12, 2014 at 5:13 AM, Henning Thielemann <schlepptop@henning-thielemann.de> 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.


The current implementation is:

instance (MonadFix m) => MonadFix (ExceptT e m) where
    mfix f = ExceptT $ mfix $ \ a -> runExceptT $ f $ case a of
        Right x -> x
        Left _ -> error "mfix ExceptT: Left"

You see, that it cannot handle the exception case. Whenever someone needs an mfix on ExceptT I strongly suggest that he first handles the exception, thus turning (ExceptT e m a) into plain (m a) and then calls 'mfix' only on (m a).


I further propose to declare the MonadFix instance as non-implementable in a way suggested in [1]:

class NoMonadFix m where

instance (NoMonadFix m) => MonadFix (ExceptT e m) where
   mfix = error "unimplementable"

where no instance of NoMonadFix exist and NoMonadFix is not exported. Whenever someone tries to call 'mfix' on 'ExceptT e m' he will get the type error, that a NoMonadFix instance on 'm' is missing and he will not be able to add it.



[1] http://ghc.haskell.org/trac/ghc/ticket/9334#comment:9
_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://www.haskell.org/mailman/listinfo/libraries