Context.agda 1.0 KB

123456789101112131415161718192021222324252627
  1. module Issue784.Context where
  2. open import Data.List using (List; []; _∷_; _++_; [_]; filter) renaming (map to mapL)
  3. import Level
  4. open import Issue784.Values
  5. record Context ℓ : Set (Level.suc ℓ) where
  6. constructor context
  7. field get : Values ℓ
  8. signature : ∀ {ℓ} → Context ℓ → Types ℓ
  9. signature = types ∘ Context.get
  10. ctxnames : ∀ {ℓ} → Context ℓ → Names
  11. ctxnames = names ∘ Context.get
  12. NonRepetitiveContext : ∀ {ℓ} → Context ℓ → _
  13. NonRepetitiveContext = NonRepetitiveNames ∘ Context.get
  14. getBySignature : ∀ {ℓ} {n : String} {A : Set ℓ} {x : Context ℓ} → (n , A) ∈ signature x → A
  15. getBySignature {x = x} = getBySignature′ {x = Context.get x} where
  16. getBySignature′ : ∀ {ℓ} {n : String} {A : Set ℓ} {x : Values ℓ} → (n , A) ∈ types x → A
  17. getBySignature′ {x = []} ()
  18. getBySignature′ {x = (_ , _ , à) ∷ _} (here {x = ._} {xs = ._} p) = ≡-elim′ proj₂ (≡-sym p) à
  19. getBySignature′ {x = _ ∷ _} (there {x = ._} {xs = ._} p) = getBySignature′ p