Original Gist

My code diverges from the original gist's code by

  • converting the unfamiliar Matryoshka-library types and names into the more familiar types and names we've been using here
  • defining algebras only via "on" (i.e. on symbol function) rather than using "onMatch" (i.e. onMatch {value: function, add: function})
  • the original paper showed how to define an expression that only allowed Value and Multiply operations. xgrommx's original gist did not have this.

The following table will help you understand the upcoming links to code:

Our Codexgrommx's code
newtype Expression fnewtype Mu f
Expression (VariantF t)MuV t
In $ inj symbol datainjMu symbol data
f a -> aAlgebra f a
Recursive t f can be better understood as t (f t) -> f t

The links: