@@ -19,6 +19,7 @@ module Type.Error
20import qualified Data.Map as Map
20import qualified Data.Map as Map
21import qualified Data.Maybe as Maybe
21import qualified Data.Maybe as Maybe
22+import Data.Monoid ((<>))
23import qualified AST.Module.Name as ModuleName
24import qualified AST.Module.Name as ModuleName
24import qualified Data.Bag as Bag
25import qualified Data.Bag as Bag
@@ -75,11 +76,6 @@ iteratedDealias tipe =
78−nameToDoc :: L.Localizer -> ModuleName.Canonical -> N.Name -> D.Doc
79−nameToDoc localizer (ModuleName.Canonical _ home) name =
80− L.toDoc localizer home name
83toDoc :: L.Localizer -> RT.Context -> Type -> D.Doc
79toDoc :: L.Localizer -> RT.Context -> Type -> D.Doc
84toDoc localizer ctx tipe =
80toDoc localizer ctx tipe =
85 case tipe of
81 case tipe of
@@ -109,7 +105,7 @@ toDoc localizer ctx tipe =
110 Type home name args ->
106 Type home name args ->
111 RT.apply ctx
107 RT.apply ctx
112− (nameToDoc localizer home name)
108+ (L.toDoc localizer home name)
113 (map (toDoc localizer RT.App) args)
109 (map (toDoc localizer RT.App) args)
115 Record fields ext ->
111 Record fields ext ->
@@ -131,7 +127,7 @@ toDoc localizer ctx tipe =
131aliasToDoc :: L.Localizer -> RT.Context -> ModuleName.Canonical -> N.Name -> [(N.Name, Type)] -> D.Doc
127aliasToDoc :: L.Localizer -> RT.Context -> ModuleName.Canonical -> N.Name -> [(N.Name, Type)] -> D.Doc
132aliasToDoc localizer ctx home name args =
128aliasToDoc localizer ctx home name args =
133 RT.apply ctx
129 RT.apply ctx
134− (nameToDoc localizer home name)
130+ (L.toDoc localizer home name)
135 (map (toDoc localizer RT.App . snd) args)
131 (map (toDoc localizer RT.App . snd) args)
@@ -273,48 +269,70 @@ toDiff localizer ctx tipe1 tipe2 =
273 diffRecord localizer fields1 ext1 fields2 ext2
269 diffRecord localizer fields1 ext1 fields2 ext2
275 (Type home1 name1 args1, Type home2 name2 args2) | home1 == home2 && name1 == name2 ->
271 (Type home1 name1 args1, Type home2 name2 args2) | home1 == home2 && name1 == name2 ->
276− RT.apply ctx (nameToDoc localizer home1 name1)
272+ RT.apply ctx (L.toDoc localizer home1 name1)
277 <$> sequenceA (zipWith (toDiff localizer RT.App) args1 args2)
273 <$> sequenceA (zipWith (toDiff localizer RT.App) args1 args2)
279 (Alias home1 name1 args1 _, Alias home2 name2 args2 _) | home1 == home2 && name1 == name2 ->
275 (Alias home1 name1 args1 _, Alias home2 name2 args2 _) | home1 == home2 && name1 == name2 ->
280− RT.apply ctx (nameToDoc localizer home1 name1)
276+ RT.apply ctx (L.toDoc localizer home1 name1)
281 <$> sequenceA (zipWith (toDiff localizer RT.App) (map snd args1) (map snd args2))
277 <$> sequenceA (zipWith (toDiff localizer RT.App) (map snd args1) (map snd args2))
283 -- start trying to find specific problems
279 -- start trying to find specific problems
281+ (Type home1 name1 args1, Type home2 name2 args2) | L.toString localizer home1 name1 == L.toString localizer home2 name2 ->
283+ (nameClashToDoc ctx localizer home1 name1 args1)
284+ (nameClashToDoc ctx localizer home2 name2 args2)
285 (Type home name [t1], t2) | isMaybe home name && isSimilar (toDiff localizer ctx t1 t2) ->
287 (Type home name [t1], t2) | isMaybe home name && isSimilar (toDiff localizer ctx t1 t2) ->
286 different
288 different
287− (RT.apply ctx (D.dullyellow (nameToDoc localizer home name)) [toDoc localizer RT.App t1])
289+ (RT.apply ctx (D.dullyellow (L.toDoc localizer home name)) [toDoc localizer RT.App t1])
288 (toDoc localizer ctx t2)
290 (toDoc localizer ctx t2)
289 (Bag.one AnythingFromMaybe)
291 (Bag.one AnythingFromMaybe)
291 (t1, Type home name [t2]) | isList home name && isSimilar (toDiff localizer ctx t1 t2) ->
293 (t1, Type home name [t2]) | isList home name && isSimilar (toDiff localizer ctx t1 t2) ->
292 different
294 different
293 (toDoc localizer ctx t1)
295 (toDoc localizer ctx t1)
294− (RT.apply ctx (D.dullyellow (nameToDoc localizer home name)) [toDoc localizer RT.App t2])
296+ (RT.apply ctx (D.dullyellow (L.toDoc localizer home name)) [toDoc localizer RT.App t2])
295 (Bag.one AnythingToList)
297 (Bag.one AnythingToList)
297− (Alias home name args t1, t2) ->
299+ (Alias home1 name1 args1 t1, t2) ->
298 case diffAliasedRecord localizer t1 t2 of
300 case diffAliasedRecord localizer t1 t2 of
299 Just (Diff _ doc2 status) ->
301 Just (Diff _ doc2 status) ->
300− Diff (D.dullyellow (aliasToDoc localizer ctx home name args)) doc2 status
302+ Diff (D.dullyellow (aliasToDoc localizer ctx home1 name1 args1)) doc2 status
302 Nothing ->
304 Nothing ->
306+ Type home2 name2 args2 | L.toString localizer home1 name1 == L.toString localizer home2 name2 ->
303− different
307+ different
308+ (nameClashToDoc ctx localizer home1 name1 (map snd args1))
309+ (nameClashToDoc ctx localizer home2 name2 args2)
304− (D.dullyellow (toDoc localizer ctx tipe1))
314+ (D.dullyellow (toDoc localizer ctx tipe1))
305− (D.dullyellow (toDoc localizer ctx tipe2))
315+ (D.dullyellow (toDoc localizer ctx tipe2))
306− Bag.empty
316+ Bag.empty
308− (t1, Alias home name args t2) ->
318+ (t1, Alias home2 name2 args2 t2) ->
309 case diffAliasedRecord localizer t1 t2 of
319 case diffAliasedRecord localizer t1 t2 of
310 Just (Diff doc1 _ status) ->
320 Just (Diff doc1 _ status) ->
311− Diff doc1 (D.dullyellow (aliasToDoc localizer ctx home name args)) status
321+ Diff doc1 (D.dullyellow (aliasToDoc localizer ctx home2 name2 args2)) status
313 Nothing ->
323 Nothing ->
325+ Type home1 name1 args1 | L.toString localizer home1 name1 == L.toString localizer home2 name2 ->
314− different
326+ different
327+ (nameClashToDoc ctx localizer home1 name1 args1)
328+ (nameClashToDoc ctx localizer home2 name2 (map snd args2))
315− (D.dullyellow (toDoc localizer ctx tipe1))
333+ (D.dullyellow (toDoc localizer ctx tipe1))
316− (D.dullyellow (toDoc localizer ctx tipe2))
334+ (D.dullyellow (toDoc localizer ctx tipe2))
317− Bag.empty
335+ Bag.empty
@@ -430,6 +448,17 @@ isSuper super tipe =
454+nameClashToDoc :: RT.Context -> L.Localizer -> ModuleName.Canonical -> N.Name -> [Type] -> D.Doc
455+nameClashToDoc ctx localizer (ModuleName.Canonical _ home) name args =
457+ (D.yellow (D.fromName home) <> D.dullyellow ("." <> D.fromName name))
458+ (map (toDoc localizer RT.App) args)
433-- DIFF ALIASED RECORD
462-- DIFF ALIASED RECORD