It looks like you're new here. If you want to get involved, click one of these buttons!
Natural numbers can be represented in Haskell as a recursive data structure
data Nat = Zero | Succ Nat
(a) Implement a type
Nat2, isomorphic to
Nat, but this time defined as an initial
algebra of a functor.
(b) Using a catamorphism, define a function
Nat2 -> Int that maps n to the n-th
(c) Define a coalgebra whose anamorphism is a (partial) function
Int -> Nat2 that
sends a non-negative Int into its fixed-point representation (ie. its representation
as a value of Nat2).