Skip to content

Instantly share code, notes, and snippets.

@useronym
Created May 17, 2016 12:05
Show Gist options
  • Save useronym/7dc5a0222e7e82c2dd1e0a1d92f8703b to your computer and use it in GitHub Desktop.
Save useronym/7dc5a0222e7e82c2dd1e0a1d92f8703b to your computer and use it in GitHub Desktop.
module Combinators where
open import Data.Nat.Base
data Mu (A : Set) : Set where
roll : A → Mu A
unroll : ∀ {A : Set} → Mu A → A
unroll (roll a) = a
Y : ∀ {A : Set} → (A → A) → A
Y = λ f → (λ x → f (unroll x x)) (roll (λ x → f (unroll x x)))
fac : (ℕ → ℕ) → ℕ → ℕ
fac f zero = suc zero
fac f n = n * f (pred n)
-- Y fac 1 → 1
-- Y fac 2 → _24 fac (_26 fac (roll (λ x → fac (_24 fac x)))) 0 + 0 + (_24 fac (_26 fac (roll (λ x → fac (_24 fac x)))) 0 + 0 + 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment