Issue3410.agda 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. open import Common.IO
  2. open import Agda.Builtin.String
  3. open import Agda.Builtin.Unit
  4. open import Agda.Builtin.Nat
  5. open import Agda.Builtin.Sigma
  6. open import Agda.Builtin.Equality
  7. open import Agda.Builtin.Bool
  8. open import Agda.Builtin.Strict
  9. data ∋⋆ : Set where
  10. Z : ∋⋆
  11. data ⊢⋆ : Set where
  12. size⋆ : Nat → ⊢⋆
  13. ⋆Sub : Set
  14. ⋆Sub = ∋⋆ → ⊢⋆
  15. data TermCon : ⊢⋆ → Set where
  16. integer : (s : Nat) → TermCon (size⋆ s)
  17. data ⊢_ : ⊢⋆ → Set where
  18. con : ∀ {s} → TermCon (size⋆ s) → ⊢ size⋆ s
  19. data Value : {A : ⊢⋆} → ⊢ A → Set where
  20. V-con : ∀ {n} → (cn : TermCon (size⋆ n)) → Value (con cn)
  21. notErased : Nat → Bool
  22. notErased n = primForce n λ _ → true
  23. BUILTIN : (σ : ⋆Sub) (vtel : Σ (⊢ σ Z) Value) → Bool
  24. BUILTIN σ vtel with σ Z
  25. BUILTIN σ (_ , V-con (integer s)) | _ = notErased s
  26. -- Either of these work:
  27. -- BUILTIN σ (_ , V-con (integer s)) | size⋆ s = notErased s
  28. -- BUILTIN σ (con (integer s) , V-con (integer s)) | _ = notErased s
  29. con2 : ⊢ size⋆ 8
  30. con2 = con (integer 8)
  31. vcon2 : Value con2
  32. vcon2 = V-con (integer 8)
  33. builtin2plus2 : Bool
  34. builtin2plus2 = BUILTIN (λ _ → size⋆ 8) (con2 , vcon2)
  35. help : Bool → String
  36. help true = "4"
  37. help false = "something went wrong"
  38. check : "4" ≡ help builtin2plus2
  39. check = refl
  40. main : IO ⊤
  41. main = putStrLn (help builtin2plus2)