[Haskell-cafe] non-exhaustive pattern match(es)?

Semen Trygubenko / Семен Тригубенко semen at trygub.com
Tue Jun 10 23:17:49 UTC 2014


Dear Haskell Cafe,

In the following program


f :: Int -> [(Int,Int)] -> [(Int,Int)] -> [(Int,Int)]
f _ cs     []          = cs
f _ []     _           = []
f i (c:cs) ((i',t):os)
    | i <  i'   = []
    | i == i'   = []
    | i >  i'   = []
--  | otherwise = []

main :: IO ()
main = do print $ f 0 [] []


without the "otherwise" clause (commented) I get the warning

example.hs:2:1: Warning:
    Pattern match(es) are non-exhaustive
    In an equation for `f':
        Patterns not matched: _ (_ : _) ((_, _) : _)

Could someone help me uncover which cases that are not… erm… covered
by the above patterns?

Many thanks,
Semen

PS This definition, on the other hand,

f _ cs     []          = cs
f _ []     _           = []
f i (c:cs) ((i',t):os) = []

is exhaustive… 


-- 
Семен Тригубенко http://trygub.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140611/79660a8a/attachment.sig>


More information about the Haskell-Cafe mailing list