||| Abstract syntax for terms. module Obs.Term import Data.Fin import Obs.Sort import Text.Bounded import Text.PrettyPrint.Prettyprinter %default total -- Definition ------------------------------------------------------------------ public export data Term : Nat -> Type where Var : Bounds -> Fin n -> Term n -- Sorts Sort : Bounds -> Sort -> Term n -- True Top : Bounds -> Term n Point : Bounds -> Term n public export record Definition (n : Nat) where constructor MkDefinition bounds : Bounds -- of the name name : String ty : Term n tm : Term n public export data Block : Nat -> Type where Nil : Block 0 (:<) : Block n -> Definition n -> Block (S n) -- Operations ------------------------------------------------------------------ export fullBounds : Term n -> Bounds fullBounds (Var x i) = x fullBounds (Sort x s) = x fullBounds (Top x) = x fullBounds (Point x) = x -- Pretty Print ---------------------------------------------------------------- export Pretty (Term n) where prettyPrec d (Var x i) = pretty "$\{show i}" prettyPrec d (Sort x s) = prettyPrec d s prettyPrec d (Top x) = pretty "()" prettyPrec d (Point x) = pretty "_" export Pretty (Definition n) where pretty def = group $ pretty def.name <++> colon <+> softline <+> pretty def.ty <+> hardline <+> pretty def.name <++> equals <+> softline <+> pretty def.tm export Pretty (Block n) where pretty [] = neutral pretty ([] :< def) = pretty def pretty (blk :< def) = pretty blk <+> hardline <+> hardline <+> pretty def