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
andMultiply
operations. xgrommx's original gist did not have this.
The following table will help you understand the upcoming links to code:
Our Code | xgrommx's code |
---|---|
newtype Expression f | newtype Mu f |
Expression (VariantF t) | MuV t |
In $ inj symbol data | injMu symbol data |
f a -> a | Algebra f a |
fold | cata Recursive t f can be better understood as t (f t) -> f t |
The links:
- Read from
ADT1.purs
toADT6.purs
: From Algebraic Data Types (ADTs) to Extensible Algebraic Data Types (EADTs). This will help us get used to the different names he uses for the same ideas - The original gist