a type theory with equality based on setoids
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

62 lines
1.2 KiB

{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE PatternSynonyms #-}
module Syntax where
import Data.Text (Text)
import Data.Data (Data, Typeable)
data Plicity
= Im
| Ex
deriving (Eq, Show, Ord, Data, Typeable)
newtype Var = Bound Int
deriving (Eq, Show, Ord, Data, Typeable)
data BoundDef = BDBound Text | BDDefined Text
deriving (Eq, Show, Ord, Data, Typeable)
newtype MetaVar = MV { getMV :: Int }
deriving (Eq, Show, Ord, Data, Typeable)
data Term
= Var Var
| Con Text
| Let Text Term Term Term
| Type | Prop
| Pi Plicity Text Term Term
| Lam Plicity Text Term
| App Plicity Term Term
| Sigma Text Term Term
| Pair Term Term
| Proj1 Term
| Proj2 Term
| Meta MetaVar
| NewMeta MetaVar [BoundDef]
| Id Term Term Term
| Refl
| Coe
| Cong
| Sym
| Top | Unit
deriving (Eq, Show, Ord, Typeable, Data)
pattern Bv :: Int -> Term
pattern Bv i = Var (Bound i)
data Telescope
= End
| Ext Telescope Text Term
deriving (Eq, Show, Ord)
newtype Level = Lvl {unLvl :: Int}
deriving (Eq, Show, Ord, Enum)
lvl2Ix :: Level -> Level -> Int
lvl2Ix (Lvl l) (Lvl x) = l - x - 1