moduleMonad{-( MonadPlus(mzero, mplus), join, guard, when, unless, ap, msum, filterM, mapAndUnzipM, zipWithM, zipWithM_, foldM, liftM, liftM2, liftM3, liftM4, liftM5, -- ...and what the Prelude exports Monad((>>=), (>>), return, fail), Functor(fmap), mapM, mapM_, sequence, sequence_, (=<<), ) -}whereimportPrelude -- The MonadPlus class definitionclass(Monadm)=>MonadPlusmwheremzero::mamplus::ma->ma->ma-- Instances of MonadPlusinstanceMonadPlusMaybewheremzero=NothingNothing`mplus`ys=ysxs`mplus`ys=xsinstanceMonadPlus[]wheremzero=[]mplus=(++) -- Functionsmsum::MonadPlusm=>[ma]->mamsumxs=foldrmplusmzeroxsjoin::(Monadm)=>m(ma)->majoinx=x>>=idwhen::(Monadm)=>Bool->m()->m()whenps=ifpthenselsereturn()unless::(Monadm)=>Bool->m()->m()unlessps=when(notp)sap::(Monadm)=>m(a->b)->ma->mbap=liftM2($) --guard :: MonadPlus m => Bool -> m ()guardp=ifpthenreturn()elsemzeromapAndUnzipM::(Monadm)=>(a->m(b,c))->[a]->m([b], [c])mapAndUnzipMfxs=sequence(mapfxs)>>=return.unzipzipWithM::(Monadm)=>(a->b->mc)->[a]->[b]->m[c]zipWithMfxsys=sequence(zipWithfxsys)zipWithM_::(Monadm)=>(a->b->mc)->[a]->[b]->m()zipWithM_fxsys=sequence_(zipWithfxsys)foldM::(Monadm)=>(a->b->ma)->a->[b]->mafoldMfa[]=returnafoldMfa(x:xs)=fax>>=\y->foldMfyxsfilterM::Monadm=>(a->mBool)->[a]->m[a]filterMp[]=return[]filterMp(x:xs)=do{b<-px;ys<-filterMpxs;return(ifbthen(x:ys)elseys) }liftM::(Monadm)=>(a->b)->(ma->mb)liftMf=\a->do{a'<-a;return(fa') }liftM2::(Monadm)=>(a->b->c)->(ma->mb->mc)liftM2f=\ab->do{a'<-a;b'<-b;return(fa'b') }liftM3::(Monadm)=>(a->b->c->d)->(ma->mb->mc->md)liftM3f=\abc->do{a'<-a;b'<-b;c'<-c;return(fa'b'c') }liftM4::(Monadm)=>(a->b->c->d->e)->(ma->mb->mc->md->me)liftM4f=\abcd->do{a'<-a;b'<-b;c'<-c;d'<-d;return(fa'b'c'd') }liftM5::(Monadm)=>(a->b->c->d->e->f)->(ma->mb->mc->md->me->mf)liftM5f=\abcde->do{a'<-a;b'<-b;c'<-c;d'<-d;e'<-e;return(fa'b'c'd'e') }

Index

(HTML for this module was generated on 2005-02-11. About the conversion tool.)