diff options
Diffstat (limited to 'receme/src/algebra.rs')
-rw-r--r-- | receme/src/algebra.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/receme/src/algebra.rs b/receme/src/algebra.rs new file mode 100644 index 0000000..49e0932 --- /dev/null +++ b/receme/src/algebra.rs @@ -0,0 +1,14 @@ +//! This file defines the algebra trait. +//! +//! If F is an endo-functor, then an F-algebra is a natural +//! transformation from F to the identity functor. + +use super::functor::Functor; + +/// An algebra is a function from F(T) to T. +/// +/// This is a "trait alias". Since Rust does not support trait alias +/// yet, we define an empty trait with an automatic implementation. +pub trait Algebra<T, F: Functor<T>>: FnMut(F) -> T {} + +impl<T, F: Functor<T>, A: FnMut(F) -> T> Algebra<T, F> for A {} |