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.

74 lines
1.4 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 [(Formula, 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 Formula
  28. = FIs1 Text
  29. | FIs0 Text
  30. | FAnd Formula Formula
  31. | FOr Formula Formula
  32. | FTop
  33. | FBot
  34. deriving (Eq, Show, Ord)
  35. data Pattern
  36. = PCon Text [Text]
  37. | PCap Text
  38. deriving (Eq, Show, Ord)
  39. data Statement
  40. = Decl [Text] Expr
  41. | Defn Text Expr
  42. | Builtin Text Text
  43. | Postulate [(Text, Expr)]
  44. | ReplNf Expr -- REPL eval
  45. | ReplTy Expr -- REPL :t
  46. | Data Text [(Text, Plicity, Expr)] Expr [(Posn, Posn, Constructor)]
  47. | SpanSt Statement Posn Posn
  48. deriving (Eq, Show, Ord)
  49. data Constructor
  50. = Point Text Expr
  51. | Path Text [Text] Expr [(Formula, Expr)]
  52. deriving (Eq, Show, Ord)
  53. data Posn
  54. = Posn { posnLine :: {-# UNPACK #-} !Int
  55. , posnColm :: {-# UNPACK #-} !Int
  56. }
  57. deriving (Eq, Show, Ord)