pub trait MonoAtop<'a,A,B,C,D> where Self:Sized{
#![allow(non_snake_case)]
fn AT<Duo>(self,d: Duo)-> Box<dyn Fn(A,B)->D + 'a>
where Self: Fn(C)->D +'a , Duo:Fn(A,B)->C +'a
{ Box::new(move|x,y|self(d(x,y))) }
}
impl<'a,A,B,C,D,Fun> MonoAtop<'a,A,B,C,D> for Fun where Fun: Fn(C)->D {}
pub trait MonoComposition<'a,B,C,D> where Self: Sized{
#![allow(non_snake_case)]
fn CP<Mono2>(self, m2: Mono2)->Box<dyn Fn(B)->D +'a>
where Self: Fn(C)->D + 'a, Mono2: Fn(B)->C + 'a
{ Box::new(move|y|self(m2(y))) }
}
impl<'a,B,C,D,Fun> MonoComposition<'a,B,C,D> for Fun where Fun: Fn(C)->D{}
pub trait DuoComposition<'a,A,B,C,D> where Self:Sized{
#![allow(non_snake_case)]
fn HK<Mono>(self,m:Mono)-> Box<dyn Fn(B,A)->D + 'a>
where Self: Fn(B,C)->D + 'a, Mono: Fn(A)->C +'a
{ Box::new(move|x,y|self(x,m(y))) }
fn RH<Mono>(self, m:Mono)-> Box<dyn Fn(A,B)->D + 'a>
where Self: Fn(B,C)->D + 'a, Mono: Fn(A)->C + 'a
{ Box::new(move|x,y|self(y,m(x))) }
}
impl<'a,A,B,C,D,Fun> DuoComposition<'a,A,B,C,D> for Fun where Fun: Fn(B,C)->D{}
pub trait DuoFlipMHook<'a,B,C,D> where Self:Sized{
#![allow(non_snake_case)]
fn FL(self)-> Box<dyn Fn(C,B)->D +'a>
where Self: Fn(B,C)->D + 'a
{ Box::new(move|x,y|self(y,x)) }
fn MH<Mono>(self, m: Mono)-> Box<dyn Fn(B)->D +'a>
where Self: Fn(B,C)->D + 'a, Mono: Fn(B)->C +'a ,B:Clone
{ Box::new(move|y|self(y.clone(),m(y))) }
}
impl<'a,B,C,D,Fun> DuoFlipMHook<'a,B,C,D> for Fun where Fun: Fn(B,C)->D{}
pub trait DuoAppose<'a,A,B,C> where Self:Sized{
#![allow(non_snake_case)]
fn AP<Mono>(self,m:Mono)-> Box<dyn Fn(A,A)->C + 'a>
where Self: Fn(B,B)->C +'a, Mono: Fn(A)->B + 'a
{ Box::new(move|x,y|self( m(x), m(y) ))}
}
impl<'a,A,B,C,Fun> DuoAppose<'a,A,B,C> for Fun where Fun: Fn(B,B)->C{}
pub trait DuoReflex<'a,B,C> where Self:Sized{
#![allow(non_snake_case)]
fn RF(self)-> Box<dyn Fn(B)->C + 'a>
where Self: Fn(B,B)->C + 'a, B:Clone
{ Box::new(move|y| self(y.clone(),y) ) }
}
impl<'a,B,C,Fun> DuoReflex<'a,B,C> for Fun where Fun: Fn(B,B)->C{}
pub fn atop<A,B,C,D,Mono,Duo>(m: Mono,d: Duo)-> impl Fn(A,B)->D
where Mono: Fn(C)->D, Duo:Fn(A,B)->C
{ move |x,y|m(d(x,y)) }
pub fn appose<A,B,C,Duo,Mono>(d:Duo,m:Mono)-> impl Fn(A,A)->C
where Duo: Fn(B,B)->C, Mono: Fn(A)->B
{ move|x,y|d( m(x), m(y) ) }
pub fn compose<B,C,D,Mono1,Mono2>(m1: Mono1, m2: Mono2)-> impl Fn(B)->D
where Mono1: Fn(C)->D, Mono2: Fn(B)->C
{ move|y|m1(m2(y)) }
pub fn hook<A,B,C,D,Duo,Mono>(d:Duo,m:Mono)-> impl Fn(A,B)->D
where Duo: Fn(A,C)->D, Mono: Fn(B)->C
{ move|x,y|d(x,m(y)) }
pub fn monohook<B,C,D,Duo,Mono>(d: Duo, m: Mono)-> impl Fn(B)->D
where Duo: Fn(B,C)->D, Mono: Fn(B)->C, B:Clone
{ move|y|d(y.clone(),m(y)) }
pub fn revhook<A,B,C,D,Duo,Mono>(d:Duo, m:Mono)-> impl Fn(A,B)->D +
where Duo: Fn(B,C)->D, Mono: Fn(A)->C
{ move|x,y|d(y,m(x)) }
pub fn reflex<B,C,Duo>(d:Duo)-> impl Fn(B)->C
where Duo: Fn(B,B)->C, B:Clone
{ move|y| d(y.clone(),y) }
pub fn flip<A,B,C,Duo>(d: Duo)-> impl Fn(B,A)->C
where Duo: Fn(A,B)->C
{ move|x,y|d(y,x) }
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
}
}