less prototype, less bad code implementation of CCHM type theory
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.

78 lines
1.5 KiB

  1. {-# LANGUAGE DeriveDataTypeable #-}
  2. module Presyntax.Presyntax where
  3. import Data.Text (Text)
  4. import Data.Data
  5. data Plicity
  6. = Im | Ex
  7. deriving (Eq, Show, Ord, Data)
  8. data Expr
  9. = Var Text
  10. | Hole
  11. | App Plicity Expr Expr
  12. | Pi Plicity Text Expr Expr
  13. | Lam Plicity Text Expr
  14. | Sigma Text Expr Expr
  15. | Pair Expr Expr
  16. | Proj1 Expr
  17. | Proj2 Expr
  18. | LamSystem [(Condition, Expr)]
  19. | LamCase [(Pattern, Expr)]
  20. | Let [LetItem] Expr
  21. | Span Expr Posn Posn
  22. deriving (Eq, Show, Ord)
  23. data LetItem
  24. = LetDecl { leIName :: Text, leIVal :: Expr }
  25. | LetBind { leIName :: Text, leIVal :: Expr }
  26. deriving (Eq, Show, Ord)
  27. data Condition
  28. = Condition { condF :: Formula, condV :: Maybe Text }
  29. deriving (Eq, Show, Ord)
  30. data Formula
  31. = FIs1 Text
  32. | FIs0 Text
  33. | FAnd Formula Formula
  34. | FOr Formula Formula
  35. | FTop
  36. | FBot
  37. deriving (Eq, Show, Ord)
  38. data Pattern
  39. = PCon Text [Text]
  40. | PCap Text
  41. deriving (Eq, Show, Ord)
  42. data Statement
  43. = Decl [Text] Expr
  44. | Defn Text Expr
  45. | Builtin Text Text
  46. | Postulate [(Text, Expr)]
  47. | ReplNf Expr -- REPL eval
  48. | ReplTy Expr -- REPL :t
  49. | Data Text [(Text, Plicity, Expr)] Expr [(Posn, Posn, Constructor)]
  50. | SpanSt Statement Posn Posn
  51. deriving (Eq, Show, Ord)
  52. data Constructor
  53. = Point Text Expr
  54. | Path Text [Text] Expr [(Formula, Expr)]
  55. deriving (Eq, Show, Ord)
  56. data Posn
  57. = Posn { posnLine :: {-# UNPACK #-} !Int
  58. , posnColm :: {-# UNPACK #-} !Int
  59. }
  60. deriving (Eq, Show, Ord)