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.

82 lines
1.6 KiB

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