1
------------------------------------------------------------------------
2
-- Environments (heterogeneous collections)
3
------------------------------------------------------------------------
5
module Data.Star.Environment (Ty : Set) where
8
open import Data.Star.List
9
open import Data.Star.Decoration
10
open import Data.Star.Pointer as Pointer hiding (lookup)
12
open import Relation.Binary.PropositionalEquality
14
-- Contexts, listing the types of all the elements in an environment.
19
-- Variables (de Bruijn indices); pointers into environments.
24
Γ ∋ σ = Any (λ _ → ⊤) (_≡_ σ) Γ
26
vz : ∀ {Γ σ} → Γ ▻ σ ∋ σ
29
vs : ∀ {Γ σ τ} → Γ ∋ τ → Γ ▻ σ ∋ τ
32
-- Environments. The T function maps types to element types.
34
Env : (Ty → Set) → Ctxt → Set
37
-- A safe lookup function for environments.
39
lookup : ∀ {Γ σ} {T : Ty → Set} → Γ ∋ σ → Env T Γ → T σ
40
lookup i ρ with Pointer.lookup i ρ
41
... | result refl x = x