-
-
Save giuliohome/bfafafa5ebb9d9357a0a663c8646cd2b to your computer and use it in GitHub Desktop.
from wikipedia Catamorphism
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type StepAlgebra b = (b, b->b) -- the algebras, which we encode as pairs (nil, next) | |
data Nat = Zero | Succ Nat -- which is the initial algebra for the functor described above | |
foldSteps :: StepAlgebra b -> (Nat -> b) -- the catamorphisms map from Nat to b | |
foldSteps (nil, next) Zero = nil | |
foldSteps (nil, next) (Succ nat) = next $ foldSteps (nil, next) nat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment