[Haskell-cafe] Warnings with OverloadedLists

Nikolay Amiantov nikoamia at gmail.com
Mon Jun 16 15:19:48 UTC 2014


Hello,
I've bumped into strange GHC behaviour with OverloadedLists and
pattern matching. Consider this example:

  {-# LANGUAGE OverloadedLists #-}

  len :: [a] -> Int
  len [] = 0
  len (_:t) = 1 + len t

If I load this with "ghci -Wall", I get a warning:
Test.hs:4:1: Warning:
    Pattern match(es) are non-exhaustive
    In an equation for ‘len’: Patterns not matched: []

If I disable OverloadedLists extension, warning goes away. Can someone
clear this behaviour out for me? It looks like a bug, but I'm not
sure.

Thanks for help,
Nikolay.


More information about the Haskell-Cafe mailing list