The following code solves exactly the problem of implementing
(restricted) MonadPlus in terms of Data.Set:
http://okmij.org/ftp/Haskell/DoRestrictedM.hs
The code is written to demonstrate the do-notation. We write the
monadic code as usual:
> test1s_do () = do
> x <- return "a"
> return $ "b" ++ x
and then instantiate it for Maybe String:
> test1sr_do :: Maybe String
> test1sr_do = unRM $ test1s_do ()
> -- Just "ba"
or for Data.Set:
> test2sr_do :: Set.Set String
> test2sr_do = unSM $ test1s_do ()
> -- fromList ["ba"]
It seems GHC 6.10 will support the do-notation even for the
generalized monads.
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe