||| Raw syntax for terms. This is before eliminating names. module Obs.Syntax import Obs.Sort import Text.Bounded import Text.PrettyPrint.Prettyprinter %default total -- Definition ------------------------------------------------------------------ public export data Syntax : Type where Var : WithBounds String -> Syntax -- Sorts Sort : Bounds -> Sort -> Syntax -- Dependent Products Pi : Bounds -> WithBounds String -> Syntax -> Syntax -> Syntax Lambda : Bounds -> WithBounds String -> Syntax -> Syntax App : Syntax -> Syntax -> Syntax -- Dependent Sums Sigma : Bounds -> WithBounds String -> Syntax -> Syntax -> Syntax Pair : Bounds -> Syntax -> Syntax -> Syntax Fst : Bounds -> Syntax -> Syntax Snd : Bounds -> Syntax -> Syntax -- True Top : Bounds -> Syntax Point : Bounds -> Syntax -- False Bottom : Bounds -> Syntax Absurd : Bounds -> Syntax -> Syntax -> Syntax public export record Definition where constructor MkDefinition bounds : Bounds -- of the name name : String ty : Syntax tm : Syntax -- Pretty Print ---------------------------------------------------------------- export Pretty Syntax where prettyPrec d (Var var) = pretty var.val prettyPrec d (Sort _ s) = prettyPrec d s prettyPrec d (Pi _ var a b) = parenthesise (d > Open) $ group $ parens (pretty var.val <++> colon <+> softline <+> prettyPrec Open a) <++> pretty "->" <+> softline <+> prettyPrec Open b prettyPrec d (Lambda _ var t) = parenthesise (d > Open) $ group $ backslash <+> pretty var.val <++> pretty "=>" <+> softline <+> prettyPrec Open t prettyPrec d (App t u) = parenthesise (d >= App) $ group $ fillSep [prettyPrec Open t, prettyPrec App u] prettyPrec d (Sigma _ var a b) = parenthesise (d >= App) $ group $ parens (pretty var.val <++> colon <+> softline <+> prettyPrec Open a) <++> pretty "**" <+> softline <+> prettyPrec Open b prettyPrec d (Pair _ t u) = angles $ group $ neutral <++> prettyPrec Open t <+> comma <+> softline <+> prettyPrec Open u <++> neutral prettyPrec d (Fst _ t) = parenthesise (d >= App) $ group $ fillSep [pretty "fst", prettyPrec App t] prettyPrec d (Snd _ t) = parenthesise (d >= App) $ group $ fillSep [pretty "snd", prettyPrec App t] prettyPrec d (Top _) = pretty "()" prettyPrec d (Point _) = pretty "tt" prettyPrec d (Bottom _) = pretty "Void" prettyPrec d (Absurd _ a t) = parenthesise (d >= App) $ group $ fillSep [pretty "absurd", prettyPrec App a, prettyPrec App t] export Pretty Definition where pretty def = group $ pretty def.name <++> colon <+> softline <+> pretty def.ty <+> hardline <+> pretty def.name <++> equals <+> softline <+> pretty def.tm