@@ -104,29 +104,27 @@ deepDealias tipe =
105dealias :: [(String, Type v)] -> Type v -> Type v
105dealias :: [(String, Type v)] -> Type v -> Type v
106dealias args tipe =
106dealias args tipe =
107− replace (Map.fromList args) tipe
107+ dealiasHelp (Map.fromList args) tipe
110−replace :: Map.Map String (Type var) -> Type var -> Type var
110+dealiasHelp :: Map.Map String (Type var) -> Type var -> Type var
111−replace typeTable t =
111+dealiasHelp typeTable tipe =
112− let go = replace typeTable in
112+ let go = dealiasHelp typeTable in
113− case t of
113+ case tipe of
114 Lambda a b ->
114 Lambda a b ->
115 Lambda (go a) (go b)
115 Lambda (go a) (go b)
118− Map.findWithDefault t x typeTable
118+ Map.findWithDefault tipe x typeTable
120 Record fields ext ->
120 Record fields ext ->
121 Record (map (second go) fields) (fmap go ext)
121 Record (map (second go) fields) (fmap go ext)
123 Aliased original args t' ->
123 Aliased original args t' ->
124− let typeTable' = foldr Map.delete typeTable (map fst args)
126− Aliased original (map (second go) args) (replace typeTable' t')
124+ Aliased original (map (second go) args) t'
128 Type _ ->
126 Type _ ->
131 App f args ->
129 App f args ->
132 App (go f) (map go args)
130 App (go f) (map go args)