@@ -34,6 +34,7 @@ import Control.Applicative
34import Control.Arrow (Arrow(..))
34import Control.Arrow (Arrow(..))
35import Control.Monad.State
35import Control.Monad.State
36import Control.Monad.Error.Class (MonadError(..))
36import Control.Monad.Error.Class (MonadError(..))
37+import Control.Monad.Writer.Class (tell)
38import Language.PureScript.AST
39import Language.PureScript.AST
39import Language.PureScript.Errors
40import Language.PureScript.Errors
@@ -83,7 +84,9 @@ entails env moduleName context = solve
83 unique :: [(a, TypeClassDictionaryInScope)] -> Check (a, TypeClassDictionaryInScope)
84 unique :: [(a, TypeClassDictionaryInScope)] -> Check (a, TypeClassDictionaryInScope)
84 unique [] = throwError . errorMessage $ NoInstanceFound className' tys'
85 unique [] = throwError . errorMessage $ NoInstanceFound className' tys'
85 unique [a] = return a
86 unique [a] = return a
87+ unique tcds | pairwise overlapping (map snd tcds) = do
86− unique tcds | pairwise overlapping (map snd tcds) = throwError . errorMessage $ OverlappingInstances className' tys' (map (tcdName . snd) tcds)
88+ tell . errorMessage $ OverlappingInstances className' tys' (map (tcdName . snd) tcds)
87 | otherwise = return (minimumBy (compare `on` length . tcdPath . snd) tcds)
90 | otherwise = return (minimumBy (compare `on` length . tcdPath . snd) tcds)
@@ -94,6 +97,8 @@ entails env moduleName context = solve
94 overlapping :: TypeClassDictionaryInScope -> TypeClassDictionaryInScope -> Bool
97 overlapping :: TypeClassDictionaryInScope -> TypeClassDictionaryInScope -> Bool
95 overlapping TypeClassDictionaryInScope{ tcdPath = _ : _ } _ = False
98 overlapping TypeClassDictionaryInScope{ tcdPath = _ : _ } _ = False
96 overlapping _ TypeClassDictionaryInScope{ tcdPath = _ : _ } = False
99 overlapping _ TypeClassDictionaryInScope{ tcdPath = _ : _ } = False
100+ overlapping TypeClassDictionaryInScope{ tcdDependencies = Nothing } _ = False
101+ overlapping _ TypeClassDictionaryInScope{ tcdDependencies = Nothing } = False
97 overlapping tcd1 tcd2 = tcdName tcd1 /= tcdName tcd2
102 overlapping tcd1 tcd2 = tcdName tcd1 /= tcdName tcd2
99 -- Create dictionaries for subgoals which still need to be solved by calling go recursively
104 -- Create dictionaries for subgoals which still need to be solved by calling go recursively