summaryrefslogtreecommitdiff
path: root/receme/src/algebra.rs
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2022-11-15 12:01:28 +0800
committerJSDurand <mmemmew@gmail.com>2022-11-15 12:01:28 +0800
commitcb7bcfad4ab0041aaf3fde3185e27ee46bb37788 (patch)
treea4fd99b138b72617b6c4c2b04f5d2655d0fedcc5 /receme/src/algebra.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/algebra.rs')
-rw-r--r--receme/src/algebra.rs14
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 {}