@@ -44,7 +44,10 @@ instance Show FC where
45data Err = Msg String
45data Err = Msg String
46 | InternalMsg String
46 | InternalMsg String
47− | CantUnify Term Term Err [(Name, Type)] Int -- Int is 'score' - how much we did unify
47+ | CantUnify Bool Term Term Err [(Name, Type)] Int
48+ -- Int is 'score' - how much we did unify
49+ -- Bool indicates recoverability, True indicates more info may make
50+ -- unification succeed
48 | NoSuchVariable Name
51 | NoSuchVariable Name
49 | NotInjective Term Term Term
52 | NotInjective Term Term Term
50 | CantResolve Term
53 | CantResolve Term
@@ -59,7 +62,7 @@ data Err = Msg String
59instance Sized Err where
62instance Sized Err where
60 size (Msg msg) = length msg
63 size (Msg msg) = length msg
61 size (InternalMsg msg) = length msg
64 size (InternalMsg msg) = length msg
62− size (CantUnify left right err _ score) = size left + size right + size err
65+ size (CantUnify _ left right err _ score) = size left + size right + size err
63 size (NoSuchVariable name) = size name
66 size (NoSuchVariable name) = size name
64 size (NotInjective l c r) = size l + size c + size r
67 size (NotInjective l c r) = size l + size c + size r
65 size (CantResolve trm) = size trm
68 size (CantResolve trm) = size trm
@@ -71,7 +74,7 @@ instance Sized Err where
71 size (Inaccessible _) = 1
74 size (Inaccessible _) = 1
73score :: Err -> Int
76score :: Err -> Int
74−score (CantUnify _ _ m _ s) = s + score m
77+score (CantUnify _ _ _ m _ s) = s + score m
75score (CantResolve _) = 20
78score (CantResolve _) = 20
76score (NoSuchVariable _) = 1000
79score (NoSuchVariable _) = 1000
77score _ = 0
80score _ = 0
@@ -79,14 +82,14 @@ score _ = 0
79instance Show Err where
82instance Show Err where
80 show (Msg s) = s
83 show (Msg s) = s
81 show (InternalMsg s) = "Internal error: " ++ show s
84 show (InternalMsg s) = "Internal error: " ++ show s
82− show (CantUnify l r e sc i) = "CantUnify " ++ show l ++ " " ++ show r ++ " "
85+ show (CantUnify _ l r e sc i) = "CantUnify " ++ show l ++ " " ++ show r ++ " "
83− ++ show e ++ " in " ++ show sc ++ " " ++ show i
86+ ++ show e ++ " in " ++ show sc ++ " " ++ show i
84 show (Inaccessible n) = show n ++ " is not an accessible pattern variable"
87 show (Inaccessible n) = show n ++ " is not an accessible pattern variable"
85 show _ = "Error"
88 show _ = "Error"
87instance Pretty Err where
90instance Pretty Err where
88 pretty (Msg m) = text m
91 pretty (Msg m) = text m
89− pretty (CantUnify l r e _ i) =
92+ pretty (CantUnify _ l r e _ i) =
90 if size l + size r > breakingSize then
93 if size l + size r > breakingSize then
91 text "Cannot unify" <+> colon $$
94 text "Cannot unify" <+> colon $$
92 nest nestingSize (pretty l <+> text "and" <+> pretty r) $$
95 nest nestingSize (pretty l <+> text "and" <+> pretty r) $$