[Haskell-cafe] Still stacking monad transformers
andrewcoppin at btinternet.com
Mon Oct 13 13:28:41 EDT 2008
Reid Barton wrote:
> It's not difficult: the operation is called
> mplus :: MyMonad a -> MyMonad a -> MyMonad a
> and already exists (assuming the author of ListT has not forgotten to
> write a MonadPlus instance).
I see... I was under the impression that "mplus" is just any arbitrary
binary operation over a given monad. How do you know what it does for a
Anyway, utilising this trick, I now have my function working quite well.
Implementing negation is the only hard part; I need to unwind everything
down to the list level, and check whether the list is empty, and do
something different depending on whether it is or it isn't:
foo = do
let x = run_some_moadic_action
if null x
This obviously fails since "x" isn't a list, it's a StateT MyState
(ListT (ErrorT MyError Ideneity)) x. I can't see a "nice" way to handle
this. I found a way that works, but it's quite ugly...
More information about the Haskell-Cafe