Hi all,
A simple question for advanced Haskellers, but I still have some
problems bending my mind over it.
Example: I have some function, that can return multiple results.
Currently I need only the first one, but in the spirit of NotJustMaybe,
I try to be as general as possible.
If I code it like this:
reduction :: (MonadPlus m) => [Rule] -> Expr -> m Expr
reduction expr = do
rule <- rules
reduction rule expr
Variable m gets unified with []. But I want m to stay as general as
possible here.
This version works, but I somehow do not like the "smell" of it
reduction expr = do
let listmonad = do
rule <- rules
reduction rule expr
msum (map return listmonad)
Is there a better way how to "embed" MonadPlus in other "MonadPlus"?
--
Gracjan
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe