on master help sign in
Improve indentation
b7c2f90Evan Czaplicki
src/AST/Expression/Canonical.hs+19−7
@@ -14,17 +14,29 @@ import qualified AST.Variable as Var
14{-| Canonicalized expressions. All variables are fully resolved to the module
14{-| Canonicalized expressions. All variables are fully resolved to the module
15they came from.
15they came from.
16-}
16-}
17+type Expr =
17−type Expr = General.Expr Annotation.Region Def Var.Canonical
18+ General.Expr Annotation.Region Def Var.Canonical
19+
20+
21+type Expr' =
18−type Expr' = General.Expr' Annotation.Region Def Var.Canonical
22+ General.Expr' Annotation.Region Def Var.Canonical
23+
19
24
20data Def = Definition Pattern.CanonicalPattern Expr (Maybe CanonicalType)
25data Def = Definition Pattern.CanonicalPattern Expr (Maybe CanonicalType)
21 deriving (Show)
26 deriving (Show)
22
27
28+
23instance Pretty Def where
29instance Pretty Def where
24 pretty (Definition pattern expr maybeTipe) =
30 pretty (Definition pattern expr maybeTipe) =
25 P.vcat [ annotation, definition ]
31 P.vcat [ annotation, definition ]
26− where
32+ where
33+ definition =
27− definition = pretty pattern <+> P.equals <+> pretty expr
34+ pretty pattern <+> P.equals <+> pretty expr
35+
36+ annotation =
28− annotation = case maybeTipe of
37+ case maybeTipe of
29− Nothing -> P.empty
38+ Nothing ->
39+ P.empty
40+
41+ Just tipe ->
30− Just tipe -> pretty pattern <+> P.colon <+> pretty tipe
42+ pretty pattern <+> P.colon <+> pretty tipe
src/AST/Expression/Source.hs+14−7
@@ -15,18 +15,25 @@ import qualified AST.Pattern as Pattern
15annotations and definitions, which is how they appear in source code and how
15annotations and definitions, which is how they appear in source code and how
16they are parsed.
16they are parsed.
17-}
17-}
18+type Expr =
18−type Expr = General.Expr Annotation.Region Def Var.Raw
19+ General.Expr Annotation.Region Def Var.Raw
20+
21+
22+type Expr' =
19−type Expr' = General.Expr' Annotation.Region Def Var.Raw
23+ General.Expr' Annotation.Region Def Var.Raw
24+
20
25
21data Def
26data Def
22 = Definition Pattern.RawPattern Expr
27 = Definition Pattern.RawPattern Expr
23 | TypeAnnotation String RawType
28 | TypeAnnotation String RawType
24 deriving (Show)
29 deriving (Show)
25
30
31+
26instance Pretty Def where
32instance Pretty Def where
27 pretty def =
33 pretty def =
28− case def of
34+ case def of
29− TypeAnnotation name tipe ->
35+ TypeAnnotation name tipe ->
30− variable name <+> P.colon <+> pretty tipe
36+ variable name <+> P.colon <+> pretty tipe
37+
31− Definition pattern expr ->
38+ Definition pattern expr ->
32− pretty pattern <+> P.equals <+> pretty expr
39+ pretty pattern <+> P.equals <+> pretty expr
src/AST/Expression/Valid.hs+19−7
@@ -15,17 +15,29 @@ import qualified AST.Pattern as Pattern
15ports are all paired with definitions in the appropriate order, it collapses
15ports are all paired with definitions in the appropriate order, it collapses
16them into a Def that is easier to work with in later phases of compilation.
16them into a Def that is easier to work with in later phases of compilation.
17-}
17-}
18+type Expr =
18−type Expr = General.Expr Annotation.Region Def Var.Raw
19+ General.Expr Annotation.Region Def Var.Raw
20+
21+
22+type Expr' =
19−type Expr' = General.Expr' Annotation.Region Def Var.Raw
23+ General.Expr' Annotation.Region Def Var.Raw
24+
20
25
21data Def = Definition Pattern.RawPattern Expr (Maybe RawType)
26data Def = Definition Pattern.RawPattern Expr (Maybe RawType)
22 deriving (Show)
27 deriving (Show)
23
28
29+
24instance Pretty Def where
30instance Pretty Def where
25 pretty (Definition pattern expr maybeTipe) =
31 pretty (Definition pattern expr maybeTipe) =
26 P.vcat [ annotation, definition ]
32 P.vcat [ annotation, definition ]
27− where
33+ where
34+ definition =
28− definition = pretty pattern <+> P.equals <+> pretty expr
35+ pretty pattern <+> P.equals <+> pretty expr
36+
37+ annotation =
29− annotation = case maybeTipe of
38+ case maybeTipe of
30− Nothing -> P.empty
39+ Nothing ->
40+ P.empty
41+
42+ Just tipe ->
31− Just tipe -> pretty pattern <+> P.colon <+> pretty tipe
43+ pretty pattern <+> P.colon <+> pretty tipe