on master help sign in
Improve indentation
7788c35Evan Czaplicki
src/Transform/Canonicalize/Type.hs+21−9
@@ -80,17 +80,29 @@ canonicalizeAlias env (name, tvars, dealiasedTipe) tipes =
80 tvarsLen = length tvars
80 tvarsLen = length tvars
81
81
82 msg :: String
82 msg :: String
83+ msg =
83− msg = "Type alias '" ++ Var.toString name ++ "' expects " ++ show tvarsLen ++
84+ "Type alias '" ++ Var.toString name ++ "' expects " ++ show tvarsLen ++
84− " type argument" ++ (if tvarsLen == 1 then "" else "s") ++
85+ " type argument" ++ (if tvarsLen == 1 then "" else "s") ++
85− " but was given " ++ show tipesLen
86+ " but was given " ++ show tipesLen
86
87
87 replace :: Map.Map String T.CanonicalType -> T.CanonicalType -> T.CanonicalType
88 replace :: Map.Map String T.CanonicalType -> T.CanonicalType -> T.CanonicalType
88 replace typeTable t =
89 replace typeTable t =
89 let go = replace typeTable in
90 let go = replace typeTable in
90 case t of
91 case t of
92+ T.Lambda a b ->
91− T.Lambda a b -> T.Lambda (go a) (go b)
93+ T.Lambda (go a) (go b)
94+
95+ T.Var x ->
92− T.Var x -> Map.findWithDefault t x typeTable
96+ Map.findWithDefault t x typeTable
97+
98+ T.Record fields ext ->
93− T.Record fields ext -> T.Record (map (second go) fields) (fmap go ext)
99+ T.Record (map (second go) fields) (fmap go ext)
100+
101+ T.Aliased original t' ->
94− T.Aliased original t' -> T.Aliased original (go t')
102+ T.Aliased original (go t')
103+
95− T.Type _ -> t
104+ T.Type _ ->
105+ t
106+
107+ T.App f args ->
96− T.App f args -> T.App (go f) (map go args)
108+ T.App (go f) (map go args)