[Haskell-cafe] YAHT: searchAll5

Magnus Therning magnus at therning.org
Mon Oct 30 20:51:33 EST 2006

I can't get searchAll5[1] in Yet Another Haskell Tutorial to run.  Ghci
complains that it can't find a MonadPlus that satisfies the required
type; it needs a MonadPlus.

I suspect this is due to the use of 'mzero' and 'mplus', without making
StateT a MonadPlus.  My thought for this was to "push" mzero into the
inner monad and have 'mplus' pass on to the inner monad:

  instance Monad m => MonadPlus (StateT state m) where
      mzero = StateT (\s -> return (s, mzero))
      (StateT m1) `mplus` (StateT m2) = StateT (\s -> do
          (s1, a) <- m1 s
          (s2, b) <- m2 s1
	  return (s2, a `mplus` b))

What's above isn't accepted by ghci, and I don't even know for sure that
my thought makes sense.


[1]: http://en.wikibooks.org/wiki/Haskell/YAHT/Monads#Monad_Transformers

Magnus Therning                             (OpenPGP: 0xAB4DFBA4)
magnus at therning.org             Jabber: magnus.therning at gmail.com

Software is not manufactured, it is something you write and publish.
Keep Europe free from software patents, we do not want censorship
by patent law on written works.

Finagle's Fifth Law:
Always draw your curves, then plot your readings.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20061031/0c3fcd8d/attachment.bin

More information about the Haskell-Cafe mailing list