moduleNumeric.Probability.EitherwhereimportControl.Monad.Instances()importControl.Applicative(Applicative,pure,(<*>),liftA2,)newtypeEitherT a m b =EitherT (m (Eithera b ))instanceFunctorm =>Functor(EitherT a m )wherefmap f (EitherT m )=EitherT $fmap(fmapf )m instanceApplicativem =>Applicative(EitherT a m )wherepure a =EitherT $pure$Righta EitherT af <*> EitherT am =EitherT $liftA2(\ef em ->caseef ofLeftb ->Leftb Rightf ->caseem ofLeftb ->Leftb Rightm ->Right$f m )af am instanceMonadm =>Monad(EitherT a m )wherereturn a =EitherT $return$Righta EitherT m >>= f =EitherT $doe <-m casee ofLeftb ->return$Leftb Righta ->casef a ofEitherT n ->n fail s =EitherT $fails throw::Applicativem =>a ->EitherT a m b throw a =EitherT $pure$Lefta 

AltStyle によって変換されたページ (->オリジナル) /