git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Partial fix for 1426
commitd8a9e415df983e09e29c8c59343726cbc6ea2a3c authorPhil Freeman <paf31@cantab.net> dateWed 26 Aug 2015, 08:39 (11 years ago) parent5fae353
4 files changed+9−5
examples/failing/OverlappingInstances.purs → examples/passing/OverlappingInstances.purs−1 examples/failing/OverlappingInstances2.purs → examples/passing/OverlappingInstances2.purs−1 src/Language/PureScript/Errors.hs+3−2 src/Language/PureScript/TypeChecker/Entailment.hs+6−1
examples/failing/OverlappingInstances.purs → examples/passing/OverlappingInstances.pursrenamed−1
@@ -1,4 +1,3 @@
1−-- @shouldFailWith OverlappingInstances
21module OverlappingInstances where
32
43import Prelude
examples/failing/OverlappingInstances2.purs → examples/passing/OverlappingInstances2.pursrenamed−1
@@ -1,4 +1,3 @@
1−-- @shouldFailWith OverlappingInstances
21module OverlappingInstances where
32
43import Prelude
src/Language/PureScript/Errors.hs+3−2
@@ -558,10 +558,11 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
558558 , line "with type"
559559 , indent $ line $ prettyPrintType t2
560560 ]
561− goSimple (OverlappingInstances nm ts ds) =
561+ goSimple (OverlappingInstances nm ts (d : ds)) =
562562 paras [ line $ "Overlapping instances found for " ++ show nm ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ ":"
563− , line $ intercalate ", " (map show ds)
563+ , indent $ paras (line (show d ++ " (chosen)") : map (line . show) ds)
564564 ]
565+ goSimple OverlappingInstances{} = error "OverlappingInstances: empty instance list"
565566 goSimple (NoInstanceFound nm ts) =
566567 line $ "No instance found for " ++ show nm ++ " " ++ unwords (map prettyPrintTypeAtom ts)
567568 goSimple (PossiblyInfiniteInstance nm ts) =
src/Language/PureScript/TypeChecker/Entailment.hs+6−1
@@ -34,6 +34,7 @@ import Control.Applicative
3434import Control.Arrow (Arrow(..))
3535import Control.Monad.State
3636import Control.Monad.Error.Class (MonadError(..))
37+import Control.Monad.Writer.Class (tell)
3738
3839import Language.PureScript.AST
3940import Language.PureScript.Errors
@@ -83,7 +84,9 @@ entails env moduleName context = solve
8384 unique :: [(a, TypeClassDictionaryInScope)] -> Check (a, TypeClassDictionaryInScope)
8485 unique [] = throwError . errorMessage $ NoInstanceFound className' tys'
8586 unique [a] = return a
86− unique tcds | pairwise overlapping (map snd tcds) = throwError . errorMessage $ OverlappingInstances className' tys' (map (tcdName . snd) tcds)
87+ unique tcds | pairwise overlapping (map snd tcds) = do
88+ tell . errorMessage $ OverlappingInstances className' tys' (map (tcdName . snd) tcds)
89+ return (head tcds)
8790 | otherwise = return (minimumBy (compare `on` length . tcdPath . snd) tcds)
8891
8992 -- |
@@ -94,6 +97,8 @@ entails env moduleName context = solve
9497 overlapping :: TypeClassDictionaryInScope -> TypeClassDictionaryInScope -> Bool
9598 overlapping TypeClassDictionaryInScope{ tcdPath = _ : _ } _ = False
9699 overlapping _ TypeClassDictionaryInScope{ tcdPath = _ : _ } = False
100+ overlapping TypeClassDictionaryInScope{ tcdDependencies = Nothing } _ = False
101+ overlapping _ TypeClassDictionaryInScope{ tcdDependencies = Nothing } = False
97102 overlapping tcd1 tcd2 = tcdName tcd1 /= tcdName tcd2
98103
99104 -- Create dictionaries for subgoals which still need to be solved by calling go recursively