Examples.agda 917 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. module Examples where
  2. open import LF
  3. open import IIRD
  4. open import IIRDr
  5. -- Some helper functions
  6. infixl 50 _+OP_
  7. _+OP_ : {I : Set}{D : I -> Set1}{E : Set1} -> OP I D E -> OP I D E -> OP I D E
  8. γ₀ +OP γ₁ = σ Two (\x -> case₂ x γ₀ γ₁)
  9. -- First something simple.
  10. bool : OPr One (\_ -> One')
  11. bool _ = ι★r +OP ι★r
  12. Bool : Set
  13. Bool = Ur bool ★
  14. false : Bool
  15. false = intror < ★₀ | ★ >
  16. true : Bool
  17. true = intror < ★₁ | ★ >
  18. -- We don't have universe subtyping, and we only setup large elimination rules.
  19. if_then_else_ : {A : Set1} -> Bool -> A -> A -> A
  20. if_then_else_ {A} b x y = Rr bool (\_ _ -> A) (\_ a _ -> case₂ (π₀ a) y x) ★ b
  21. -- Something recursive
  22. nat : OPr One (\_ -> One')
  23. nat _ = ι★r +OP δ One (\_ -> ★) (\_ -> ι★r)
  24. Nat : Set
  25. Nat = Ur nat ★
  26. zero : Nat
  27. zero = intror < ★₀ | ★ >
  28. suc : Nat -> Nat
  29. suc n = intror < ★₁ | < (\_ -> n) | ★ > >