diff options
author | JSDurand <mmemmew@gmail.com> | 2022-11-15 12:01:28 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2022-11-15 12:01:28 +0800 |
commit | cb7bcfad4ab0041aaf3fde3185e27ee46bb37788 (patch) | |
tree | a4fd99b138b72617b6c4c2b04f5d2655d0fedcc5 /receme/src/coalgebra.rs |
Initial commit
Basic GNU standard files are added, and we now stop worrying about
monadic anamorphisms.
The current focus is on testing the correctness of the algorithm, so I
need convenient support for manipulating, interpreting, examining, and
per chance animating nondeterministic automata.
Diffstat (limited to 'receme/src/coalgebra.rs')
-rw-r--r-- | receme/src/coalgebra.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/receme/src/coalgebra.rs b/receme/src/coalgebra.rs new file mode 100644 index 0000000..5974d90 --- /dev/null +++ b/receme/src/coalgebra.rs @@ -0,0 +1,14 @@ +//! This file defines the co-algebra trait. +//! +//! If F is an endo-functor, then an F-co-algebra is a natural +//! transformation from the identity functor to F. + +use super::functor::Functor; + +/// A co-algebra is a function from T to F(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 Coalgebra<T, F: Functor<T>>: FnMut(T) -> F {} + +impl<T, F: Functor<T>, C: FnMut(T) -> F> Coalgebra<T, F> for C {} |