Cont as Monoid
David Menendez
zednenem at psualum.com
Sun Sep 9 10:27:26 EDT 2007
On 9/8/07, Conal Elliott <conal at conal.net> wrote:
> I'd like to see the following addition to Control.Monad.Cont in mtl:
>
> instance Monoid r => Monoid (Cont r a) where
> mempty = Cont mempty
> m `mappend` m' = Cont (runCont m `mappend` runCont m')
Alternatively,
instance Monoid r => MonadPlus (Cont r a) where
mzero = Cont mempty
mplus a b = Cont $ runCont a `mappend` runCont b
"Cont (Endo b) a" is the usual backtracking monad.
More information about the Libraries
mailing list