Let's say `n` is a natural number then `C(n)` is the Church encoding of that natural number. `C(n)` is a function of two arguments called, traditionally, `succ` and `zero` such that
C(n)(succ, zero) = succ(succ(succ(succ(...succ(zero)))))
where `succ` is applied `n` times. So if you have a normal datatype encoding of natural numbers
data Nat = Zero | Succ Nat
then you can convert Church numerals to that data type very trivially
C(n)(Succ, Zero)
To maybe see the pattern a little more clearly, let's consider something very similar to Naturals---linked lists!
The Church encoding of a linked list, `l`, (also known as its right fold or recursor) is a function of two arguments traditionally called `cons` and `nil`
C(l)(cons, nil)
such that the following equations hold
C([] )(cons, nil) = nil
C(a : as)(cons, nil) = cons a (C(as)(cons, nil))
In other words, it changes a list like
a : b : c : d : e : f : []
into
cons a (cons b (cons c (cons d (cons e (cons f nil)))))
for whatever the choice of `cons` and `nil` were. Again, if we take the standard constructors for a List
data List a = Nil | Cons a (List a)
then we can apply them to the Church encoding to immediately transform it into its data type
C(l)(Cons, Nil)
Finally, take note that the `cons` function here is the same as the "reduction function" talked about so much in Clojure transducers (also: everywhere else). It's really fundamental to the type of lists and streams.