<div dir="ltr">Hello,<div><br></div><div>I have a newtype for a monad transformer stack:</div><div><br></div><div><div>newtype MyMonad a = MyMonad { runMyMonad :: ((ReaderT Env (ExceptT String (StateT Store (ListT Identity)))) a) }</div></div><div><br></div><div>and I'd like to it derive MonadPlus. The default instance for MonadPlus I get via GeneralizedNewtypeDeriving is the ExceptT one because it is the outermost transformer implementing MonadPlus. I would like to use the ListT instance instead. The best solution I have come up with is to define:</div><div><br></div><div><div>instance MonadPlus MyMonad where</div><div>  mzero = MyMonad $ ReaderT $ \e -> ExceptT $ StateT $ \s -> ListT $ Identity []</div><div>  mplus a b =</div><div>    MyMonad $ ReaderT $ \e -> ExceptT $ StateT $ \s -> ListT $ Identity $</div><div>      let</div><div>        run x = runIdentity (runListT (runStateT (runExceptT (runReaderT (runAbstract x) e)) s))</div><div>        as = run a</div><div>        bs = run b</div><div>      in</div><div>        as ++ bs</div></div><div><br></div><div>My questions are:</div><div>  - Is there a shorter way to define mplus?</div><div>  - Is there maybe some variation of monad transformer stacks where the layers are named and can be accessed by name? (I know of effects handlers but I'd like to stick to monad transformers for now.)</div><div><br></div><div>Paul</div></div>