on 5111919 help sign in
elk/src/AST/Expression/Source.hs
39 lines 953 B history raw
1{-# OPTIONS_GHC -Wall #-}
3module AST.Expression.Source where
5import AST.PrettyPrint
6import Text.PrettyPrint as P
7import qualified AST.Expression.General as General
8import AST.Type (RawType)
9import qualified AST.Variable as Var
10import qualified AST.Annotation as Annotation
11import qualified AST.Pattern as Pattern
14{-| Expressions created by the parser. These use a split representation of type
15annotations and definitions, which is how they appear in source code and how
16they are parsed.
17-}
18type Expr =
19 General.Expr Annotation.Region Def Var.Raw
22type Expr' =
23 General.Expr' Annotation.Region Def Var.Raw
26data Def
27 = Definition Pattern.RawPattern Expr
28 | TypeAnnotation String RawType
29 deriving (Show)
32instance Pretty Def where
33 pretty def =
34 case def of
35 TypeAnnotation name tipe ->
36 variable name <+> P.colon <+> pretty tipe
38 Definition pattern expr ->
39 pretty pattern <+> P.equals <+> pretty expr