Derivatives for Containers in Univalent Foundations
Cubical.Reflection.Base
Initializing search
    phijor/derivatives
    • Overview
    • Library
    phijor/derivatives
    • Overview
      • Derivative.Bag
      • Derivative.Adjunction
      • Derivative.Basics.Sum
      • Derivative.Basics.Unit
      • Derivative.Basics.W
      • Derivative.Basics.Decidable
      • Derivative.Basics.Embedding
      • Derivative.Basics.Equiv
      • Derivative.Basics.Maybe
      • Derivative.Basics.Sigma
      • Derivative.Category
      • Derivative.ChainRule
      • Derivative.Container
      • Derivative.Derivative
      • Derivative.Indexed.Mu
      • Derivative.Indexed.ChainRule
      • Derivative.Indexed.Container
      • Derivative.Indexed.Derivative
      • Derivative.Indexed.MuRule
      • Derivative.Indexed.Univalence
      • Derivative.Isolated.Base
      • Derivative.Isolated
      • Derivative.Isolated.S1
      • Derivative.Isolated.Sum
      • Derivative.Isolated.W
      • Derivative.Isolated.DependentGrafting
      • Derivative.Isolated.Grafting
      • Derivative.Isolated.Maybe
      • Derivative.Isolated.Sigma
      • Derivative.Prelude
      • Derivative.Properties
      • Derivative.Remove

    Cubical.Reflection.Base

    {-
    
    Some basic utilities for reflection
    
    -}
    {-# OPTIONS --no-exact-split #-}
    module Cubical.Reflection.Base where
    
    open import Cubical.Foundations.Prelude
    open import Cubical.Data.List.Base
    open import Cubical.Data.Nat.Base
    
    import Agda.Builtin.Reflection as R
    open import Agda.Builtin.String
    
    _>>=_ = R.bindTC
    _<|>_ = R.catchTC
    
    _>>_ : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → R.TC A → R.TC B → R.TC B
    f >> g = f >>= λ _ → g
    
    infixl 4 _>>=_ _>>_ _<|>_
    
    liftTC : ∀ {ℓ ℓ'} {A : Type ℓ} {B : Type ℓ'} → (A → B) → R.TC A → R.TC B
    liftTC f ta = ta >>= λ a → R.returnTC (f a)
    
    v : ℕ → R.Term
    v n = R.var n []
    
    pattern varg t = R.arg (R.arg-info R.visible (R.modality R.relevant R.quantity-ω)) t
    pattern harg {q = q} t = R.arg (R.arg-info R.hidden (R.modality R.relevant q)) t
    pattern _v∷_ a l = varg a ∷ l
    pattern _h∷_ a l = harg a ∷ l
    
    infixr 5 _v∷_ _h∷_
    
    vlam : String → R.Term → R.Term
    vlam str t = R.lam R.visible (R.abs str t)
    
    hlam : String → R.Term → R.Term
    hlam str t = R.lam R.hidden (R.abs str t)
    
    newMeta = R.checkType R.unknown
    
    makeAuxiliaryDef : String → R.Type → R.Term → R.TC R.Term
    makeAuxiliaryDef s ty term =
      R.freshName s >>= λ name →
      R.declareDef (varg name) ty >>
      R.defineFun name [ R.clause [] [] term ] >>
      R.returnTC (R.def name [])
    
    Made with Material for MkDocs