pi/src/Term.idr

28 lines
899 B
Idris

module Term
import Data.Nat
import Misc
%default total
{-
The type of terms is indexed by the size of the environment in which
they are valid, that is, it is impossible to construct an ill-scoped term.
-}
public export
data Term : (_ : Index) -> Type where
TType : Term n -- Type of types
TLam : Term (S n) -> Term n -- Lambda abstraction (λ _ . Scope)
TPi : Term n -> Term (S n) -> Term n -- Pi type (∏ _ : A . B _ )
TApp : Term n -> Term n -> Term n -- Appliction
TVar : (n : Nat) -> LT n m -> Term m -- Variable
public export
Show (Term n) where
show TType = "TType"
show (TLam sc) = "TLam (" ++ show sc ++ ")"
show (TPi ty sc) = "TPi (" ++ show ty ++ ") (" ++ show sc ++ ")"
show (TApp f x) = "TApp (" ++ show f ++ ") (" ++ show x ++ ")"
show (TVar i _) = "TVar " ++ show i