summaryrefslogtreecommitdiff
path: root/receme/src/algebra.rs
blob: 49e0932ba2a1e4e528fc4f9e6aee46077bcce0ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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 {}