public static M1 Bind <M0, M1, T0, T1, T2>(this TEither <T0, T1> .ParentType <M0> monad, Func <T0, IMonad <M1, T2, T1> > m) where M0 : IMonad <M0, T0, T1> where M1 : IMonad <M1, T2, T1> where T0 : class where T1 : class where T2 : class { return((M1)monad.Match(m, (e) => new Factory <M1, T1>(monad, e).Instance())); }
public static Either <T0, T2> Fmap <F0, T0, T1, T2>( this TEither <T0, T1> .P <F0> e, Func <T1, T2> f ) where F0 : TFunctor <T1> .T <T0> .P <F0> { return(e .Match( (l) => new Factory <Either <T0, T2> >(l).Instance(), (r) => new Factory <Either <T0, T2> >(f(r)).Instance() )); }
public static M1 Bind <M0, M1, T0, T1, T2>( this TEither <T0, T1> .P <M0> e, Func <T1, TMonad <T2> .T <T0> .P <M1> > fm ) where M0 : TMonad <T1> .T <T0> .P <M0> { return(e .Match( (l) => new Factory <M1>(l).Instance(), (r) => (M1)fm(r) )); }
public static Either <T0, TR> Apply <A0, A1, T0, TI, TR>( this TEither <T0, IFunc <TI, TR> > .P <A0> a, TEither <T0, TI> .P <A1> fm ) where A0 : TApplicative <IFunc <TI, TR> > .T <T0> .P <A0> where A1 : TApplicative <TI> .T <T0> .P <A1> { return(a.Match( (l) => new Factory <Either <T0, TR> >(l).Instance(), (r) => fm .Match( (ll) => new Factory <Either <T0, TR> >(ll).Instance(), (rr) => new Factory <Either <T0, TR> >(r.Execute(rr)).Instance() ) )); }