on master help sign in
Return a non-empty list of errors in Type.Solve and Nitpick.PatternMatches

If these functions fail, there is a guarantee that we have at least one error to show. Now that is captured in the types.

commitfa9aba204b91aa2fef89219765a01f114be70824 authorEvan Czaplicki <evancz@users.noreply.github.com> dateTue 30 Apr 2019, 18:31 (8 years ago) parent5b0204d
2 files changed+8−6
compiler/src/Nitpick/PatternMatches.hs+4−3 compiler/src/Type/Solve.hs+4−3
compiler/src/Nitpick/PatternMatches.hs+4−3
@@ -21,6 +21,7 @@ import qualified Data.List as List
2121import qualified Data.Map as Map
2222import qualified Data.Maybe as Maybe
2323import qualified Data.Name as Name
24+import qualified Data.NonEmptyList as NE
2425import qualified Data.Utf8 as Utf8
2526
2627import qualified AST.Canonical as Can
@@ -202,14 +203,14 @@ data Context
202203-- CHECK
203204
204205
205−check :: Can.Module -> Either [Error] ()
206+check :: Can.Module -> Either (NE.List Error) ()
206207check (Can.Module _ _ decls _ _ _ _) =
207208 case checkDecls decls [] of
208209 [] ->
209210 Right ()
210211
211− errors ->
212− Left errors
212+ e:es ->
213+ Left (NE.List e es)
213214
214215
215216
compiler/src/Type/Solve.hs+4−3
@@ -10,6 +10,7 @@ import Control.Monad
1010import qualified Data.Map.Strict as Map
1111import Data.Map.Strict ((!))
1212import qualified Data.Name as Name
13+import qualified Data.NonEmptyList as NE
1314import qualified Data.Vector as Vector
1415import qualified Data.Vector.Mutable as MVector
1516
@@ -29,7 +30,7 @@ import qualified Type.UnionFind as UF
2930-- RUN SOLVER
3031
3132
32−run :: Constraint -> IO (Either [Error.Error] (Map.Map Name.Name Can.Annotation))
33+run :: Constraint -> IO (Either (NE.List Error.Error) (Map.Map Name.Name Can.Annotation))
3334run constraint =
3435 do pools <- MVector.replicate 8 []
3536
@@ -40,8 +41,8 @@ run constraint =
4041 [] ->
4142 Right <$> traverse Type.toAnnotation env
4243
43− _ ->
44− return $ Left errors
44+ e:es ->
45+ return $ Left (NE.List e es)
4546
4647
4748