Skip to main content

karpal_arrow/
arrow_loop.rs

1use crate::arrow::Arrow;
2
3/// ArrowLoop: an Arrow with a loop/fixpoint combinator.
4///
5/// Takes an arrow from `(A, D)` to `(B, D)` and produces an arrow from `A` to `B`,
6/// where `D` is the "feedback" type threaded through the loop.
7///
8/// In Haskell, `loop` relies on laziness to tie the knot. Rust is strict, so
9/// `D: Default` provides the initial feedback seed and the implementation uses
10/// single-pass evaluation.
11pub trait ArrowLoop: Arrow {
12    fn loop_arrow<A: Clone + 'static, B: Clone + 'static, D: Default + Clone + 'static>(
13        f: Self::P<(A, D), (B, D)>,
14    ) -> Self::P<A, B>;
15}