//! This file defines the behaviours of R-co-algebras. //! //! For a functor F, an R-co-algebra is a natural transformation from //! the identity functor to F1, where F1 is the functor that sends T //! to F(F(T) + T), where the + is the categorical co-product, //! represented in Rust as `Result`. And the F(T) variant means to //! short-circuit the expansion. use crate::functor::Functor; /// An R-co-algebra is a function from T to F(Result). /// /// This is a "trait alias". Since Rust does not support trait alias /// yet, we define an empty trait with an automatic implementation. pub trait Coralgebra: FnMut(T) -> G where F: Functor, G: Functor>, { } impl Coralgebra for R where F: Functor, G: Functor>, R: FnMut(T) -> G, { }