Skip to content

Commit

Permalink
Remove some incomplete pattern matches (#299)
Browse files Browse the repository at this point in the history
* Remove incomplete pattern matches

They only appear when linear-base with ghc HEAD (`ab5fd982`, slightly
newer than GHC 9.0.1 release). Likely the recent pattern exhaustiveness
checking are relevant, but I don't know why the released version do not throw
these errors.
  • Loading branch information
utdemir authored Feb 10, 2021
1 parent f964890 commit 8b84358
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/Data/List/Linear.hs
Original file line number Diff line number Diff line change
Expand Up @@ -295,17 +295,26 @@ scanl1 f (x:xs) = scanl f x xs
scanr :: Dupable b => (a %1-> b %1-> b) -> b %1-> [a] %1-> [b]
scanr _ b [] = [b]
scanr f b (a:as) =
scanr f b as & \(b':bs') ->
dup2 b' & \(b'', b''') ->
f a b'' : b''' : bs'
scanr f b as & \case
(b':bs') ->
dup2 b' & \(b'', b''') ->
f a b'' : b''' : bs'
[] ->
-- this branch is impossible since scanr never returns an empty list.
Prelude.error "impossible" a

scanr1 :: Dupable a => (a %1-> a %1-> a) -> [a] %1-> [a]
scanr1 _ [] = []
scanr1 _ [a] = [a]
scanr1 f (a:as) =
scanr1 f as & \(a':as') ->
dup2 a' & \(a'', a''') ->
f a a'' : a''' : as'
scanr1 f as & \case
(a':as') ->
dup2 a' & \(a'', a''') ->
f a a'' : a''' : as'
[] ->
-- this branch is impossible since we know that the 'scanr1' result will
-- be non-empty since 'as' is also non-empty.
Prelude.error "impossible" a

replicate :: Dupable a => Int -> a %1-> [a]
replicate i a
Expand Down

0 comments on commit 8b84358

Please sign in to comment.