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.

72 lines
1.3 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. | App Plicity Expr Expr
  11. | Pi Plicity Text Expr Expr
  12. | Lam Plicity Text Expr
  13. | Sigma Text Expr Expr
  14. | Pair Expr Expr
  15. | Proj1 Expr
  16. | Proj2 Expr
  17. | LamSystem [(Condition, Expr)]
  18. | LamCase [(Pattern, Expr)]
  19. | Let [LetItem] Expr
  20. | Span Expr Posn Posn
  21. deriving (Eq, Show, Ord)
  22. data LetItem
  23. = LetDecl { leIName :: Text, leIVal :: Expr }
  24. | LetBind { leIName :: Text, leIVal :: Expr }
  25. deriving (Eq, Show, Ord)
  26. data Condition
  27. = Condition { condF :: Formula, condV :: Maybe Text }
  28. deriving (Eq, Show, Ord)
  29. data Formula
  30. = FIs1 Text
  31. | FIs0 Text
  32. | FAnd Formula Formula
  33. | FOr Formula Formula
  34. | FTop
  35. | FBot
  36. deriving (Eq, Show, Ord)
  37. data Pattern
  38. = PCon Text [Text]
  39. | PCap Text
  40. deriving (Eq, Show, Ord)
  41. data Statement
  42. = Decl [Text] Expr
  43. | Defn Text Expr
  44. | Builtin Text Text
  45. | Postulate [(Text, Expr)]
  46. | ReplNf Expr -- REPL eval
  47. | ReplTy Expr -- REPL :t
  48. | Data Text [(Text, Plicity, Expr)] Expr [(Text, Expr)]
  49. | SpanSt Statement Posn Posn
  50. deriving (Eq, Show, Ord)
  51. data Posn
  52. = Posn { posnLine :: {-# UNPACK #-} !Int
  53. , posnColm :: {-# UNPACK #-} !Int
  54. }
  55. deriving (Eq, Show, Ord)