1. 8

  2. 2

    It’s usually easy to review a pattern match and ensure there are no missing cases, although the compiler can’t help you much if you do forget one.

    But it does!

    interleave :: [a] -> [a] -> [a]
    interleave []     ys     = ys
    interleave xs     []     = xs


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

      Yeah, I should be less down on -Wall there. I’ll edit it.

      For clarity: it’s easy to write case statements or pattern matches in Haskell which are undecidable, so it’s not possible to ensure exhaustiveness in general… but it can do a good job for simple cases like this.