git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Merge pull request #1395 from nicodelpiano/master
dfba11fPhil Freeman
core-tests/tests/generic-deriving/Main.purs+5
@@ -4,11 +4,16 @@ import Prelude
4
4
5import Data.Generic
5import Data.Generic
6
6
7+data Void
8+
9+derive instance genericVoid :: Generic Void
10+
7data A a
11data A a
8 = A Number String
12 = A Number String
9 | B Int
13 | B Int
10 | C (Array (A a))
14 | C (Array (A a))
11 | D { a :: a }
15 | D { a :: a }
16+ | E Void
12
17
13derive instance genericA :: (Generic a) => Generic (A a)
18derive instance genericA :: (Generic a) => Generic (A a)
14
19
src/Language/PureScript/Linter/Exhaustive.hs+3−8
@@ -228,8 +228,8 @@ missingAlternative env mn ca uncovered
228-- it partitions that set with the new uncovered cases, until it consumes the whole set of clauses.
228-- it partitions that set with the new uncovered cases, until it consumes the whole set of clauses.
229-- Then, returns the uncovered set of case alternatives.
229-- Then, returns the uncovered set of case alternatives.
230--
230--
231−checkExhaustive :: forall m. (MonadWriter MultipleErrors m) => Environment -> ModuleName -> [CaseAlternative] -> m ()
231+checkExhaustive :: forall m. (MonadWriter MultipleErrors m) => Environment -> ModuleName -> Int -> [CaseAlternative] -> m ()
232−checkExhaustive env mn cas = makeResult . first nub $ foldl' step ([initial], (pure True, [])) cas
232+checkExhaustive env mn numArgs cas = makeResult . first nub $ foldl' step ([initialize numArgs], (pure True, [])) cas
233 where
233 where
234 step :: ([[Binder]], (Maybe Bool, [[Binder]])) -> CaseAlternative -> ([[Binder]], (Maybe Bool, [[Binder]]))
234 step :: ([[Binder]], (Maybe Bool, [[Binder]])) -> CaseAlternative -> ([[Binder]], (Maybe Bool, [[Binder]]))
235 step (uncovered, (nec, redundant)) ca =
235 step (uncovered, (nec, redundant)) ca =
@@ -240,11 +240,6 @@ checkExhaustive env mn cas = makeResult . first nub $ foldl' step ([initial], (p
240 where
240 where
241 sequenceA = foldr (liftA2 (:)) (pure [])
241 sequenceA = foldr (liftA2 (:)) (pure [])
242
242
243− initial :: [Binder]
244− initial = initialize numArgs
245− where
246− numArgs = length . caseAlternativeBinders . head $ cas
247−
248 makeResult :: ([[Binder]], (Maybe Bool, [[Binder]])) -> m ()
243 makeResult :: ([[Binder]], (Maybe Bool, [[Binder]])) -> m ()
249 makeResult (bss, (_, bss')) =
244 makeResult (bss, (_, bss')) =
250 do unless (null bss) tellExhaustive
245 do unless (null bss) tellExhaustive
@@ -274,7 +269,7 @@ checkExhaustiveDecls env mn ds =
274 in mapM_ f' ds
269 in mapM_ f' ds
275 where
270 where
276 checkExpr :: Expr -> m Expr
271 checkExpr :: Expr -> m Expr
277− checkExpr c@(Case _ cas) = checkExhaustive env mn cas >> return c
272+ checkExpr c@(Case expr cas) = checkExhaustive env mn (length expr) cas >> return c
278 checkExpr other = return other
273 checkExpr other = return other
279
274
280-- |
275-- |