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

  1. {-# LANGUAGE DeriveDataTypeable #-}
  2. {-# LANGUAGE GeneralizedNewtypeDeriving #-}
  3. {-# LANGUAGE PatternSynonyms #-}
  4. module Syntax where
  5. import Data.Text (Text)
  6. import Data.Data (Data, Typeable)
  7. data Plicity
  8. = Im
  9. | Ex
  10. deriving (Eq, Show, Ord, Data, Typeable)
  11. newtype Var = Bound Int
  12. deriving (Eq, Show, Ord, Data, Typeable)
  13. data BoundDef = BDBound Text | BDDefined Text
  14. deriving (Eq, Show, Ord, Data, Typeable)
  15. newtype MetaVar = MV { getMV :: Int }
  16. deriving (Eq, Show, Ord, Data, Typeable)
  17. data Term
  18. = Var Var
  19. | Con Text
  20. | Let Text Term Term Term
  21. | Type | Prop
  22. | Pi Plicity Text Term Term
  23. | Lam Plicity Text Term
  24. | App Plicity Term Term
  25. | Sigma Text Term Term
  26. | Pair Term Term
  27. | Proj1 Term
  28. | Proj2 Term
  29. | Meta MetaVar
  30. | NewMeta MetaVar [BoundDef]
  31. | Id Term Term Term
  32. | Refl
  33. | Coe
  34. | Cong
  35. | Sym
  36. | Top | Unit
  37. deriving (Eq, Show, Ord, Typeable, Data)
  38. pattern Bv :: Int -> Term
  39. pattern Bv i = Var (Bound i)
  40. data Telescope
  41. = End
  42. | Ext Telescope Text Term
  43. deriving (Eq, Show, Ord)
  44. newtype Level = Lvl {unLvl :: Int}
  45. deriving (Eq, Show, Ord, Enum)
  46. lvl2Ix :: Level -> Level -> Int
  47. lvl2Ix (Lvl l) (Lvl x) = l - x - 1