Skip to content

Instantly share code, notes, and snippets.

@ClarkeRemy
Created July 17, 2024 13:42
Show Gist options
  • Save ClarkeRemy/aaf666bd2aa8ba9848f06900384423b4 to your computer and use it in GitHub Desktop.
Save ClarkeRemy/aaf666bd2aa8ba9848f06900384423b4 to your computer and use it in GitHub Desktop.
Recursion schemes first steps
// struct FixSexpr(Sexpr<alloc::boxed::Box<FixSexpr>>);
enum SExpr<A=()> {
Ground(Arc<str>),
Var(i64),
App(App<A>)
}
struct App<A> { f : A, a : A}
trait Functor {
type F<T>;
}
trait Indirect {
type I<T>;
}
struct FixPoint<F : Functor, I : Indirect>(F::F<I::I<FixPoint<F,I>>>);
enum SExpresion {}
enum Boxed {}
impl Functor for SExpresion {
type F<T> = SExpr<T>;
}
impl Indirect for Boxed {
type I<T> = Box<T>;
}
type SexprFix = FixPoint<SExpresion, Boxed>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment