1
{-# OPTIONS --universe-polymorphism #-}
2
module Reflection where
4
open import Common.Prelude hiding (Unit; module Unit) renaming (Nat to ℕ)
5
open import Common.Reflect
7
data _≡_ {a}{A : Set a}(x : A) : A → Set a where
10
{-# BUILTIN EQUALITY _≡_ #-}
11
{-# BUILTIN REFL refl #-}
13
data Id {A : Set}(x : A) : (B : Set) → B → Set where
17
primTrustMe : ∀{a}{A : Set a}{x y : A} → x ≡ y
19
open import Common.Level
24
argᵛʳ : ∀{A} → A → Arg A
25
argᵛʳ = arg visible relevant
27
argʰʳ : ∀{A} → A → Arg A
28
argʰʳ = arg hidden relevant
37
set₀ = el₁ (sort (lit 0))
40
unCheck (def x (_ ∷ _ ∷ arg _ _ t ∷ [])) = t
44
data Check {a}{A : Set a}(x : A) : Set where
45
_is_of_ : (t t′ : Term) →
46
Id (primTrustMe {x = unCheck t} {t′}
48
(t′ ≡ t′) refl → Check x
53
test₁ : Check ({A : Set} → A → A)
54
test₁ = quoteGoal t in
55
t is pi (argʰʳ set₀) (el₀ (pi (argᵛʳ (el₀ (var 0 []))) (el₀ (var 1 []))))
58
test₂ : (X : Set) → Check (λ (x : X) → x)
59
test₂ X = quoteGoal t in
60
t is lam visible (var 0 []) of course
64
_`∷_ : Term → Term → Term
65
x `∷ xs = con (quote _∷_) (argᵛʳ x ∷ argᵛʳ xs ∷ [])
66
`[] = con (quote []) []
67
`true = con (quote true) []
68
`false = con (quote false) []
70
test₃ : Check (true ∷ false ∷ [])
71
test₃ = quoteGoal t in
72
t is `true `∷ `false `∷ `[] of course
75
`List A = def (quote List) (argᵛʳ A ∷ [])
79
`Term = def (quote Term) []
81
`Type = def (quote Type) []
83
`Sort = def (quote Sort) []
85
test₄ : Check (List ℕ)
86
test₄ = quoteGoal t in
87
t is `List `ℕ of course
89
test₅ : primQNameType (quote Term) ≡ set₀
92
test₆ : unEl (primQNameType (quote set₀)) ≡ `Type
95
test₇ : primQNameType (quote Sort.lit) ≡ el₀ (pi (argᵛʳ (el₀ `ℕ)) (el₀ `Sort))
102
test₈ : dataDef ℕdef ≡ primQNameDefinition (quote ℕ)
105
test₉ : primDataConstructors ℕdef ≡ quote ℕ.zero ∷ quote ℕ.suc ∷ []
108
test₁₀ : primQNameDefinition (quote ℕ.zero) ≡ dataConstructor
114
test₁₁ : primQNameDefinition (quote a) ≡ axiom
117
test₁₂ : primQNameDefinition (quote primQNameDefinition) ≡ prim
120
record Unit : Set where
126
test₁₃ : recordDef UnitDef ≡ primQNameDefinition (quote Unit)
130
test₁₄ = quoteGoal t in
131
t is con (quote ℕ.suc) (argᵛʳ (con (quote ℕ.zero) []) ∷ [])