Skip to content

Instantly share code, notes, and snippets.

@gallais
Created February 23, 2015 15:27
Show Gist options
  • Save gallais/699274bc576f5040faf0 to your computer and use it in GitHub Desktop.
Save gallais/699274bc576f5040faf0 to your computer and use it in GitHub Desktop.
Descriptions
module tfix where
open import Data.Unit
open import Data.Product
data Desc : Set₁ where
arg : (A : Set) (d : A → Desc) → Desc
rec : (r : Desc) → Desc
ret : Desc
infix 5 ⟦_⟧_
⟦_⟧_ : Desc → Set → Set
⟦ arg A d ⟧ X = Σ[ a ∈ A ] ⟦ d a ⟧ X
⟦ rec d ⟧ X = X × ⟦ d ⟧ X
⟦ ret ⟧ X = ⊤
data Fix (d : Desc) : Set where
⟨_⟩ : ⟦ d ⟧ (Fix d) → Fix d
open import Data.Bool
open import Function
t : Desc
t = arg Bool λ { true {- TInt -} → ret
; false {- TArrow -} → rec $ rec ret }
fixt : Set
fixt = Fix t
pattern TInt = ⟨ true , tt ⟩
pattern TArrow a b = ⟨ false , a , b , tt ⟩
Int→Int : fixt
Int→Int = TArrow TInt TInt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment