[Haskell-cafe] Warnings with OverloadedLists

Nikolay Amiantov nikoamia at gmail.com
Wed Jun 18 11:55:24 UTC 2014


Hi Ozgur,

On Wed, Jun 18, 2014 at 1:46 AM, Ozgur Akgun <ozgurakgun at gmail.com> wrote:
> I am not sure if this is a bug or not, but this page seems to explain the
> desugaring of patterns with OverloadedLists:
> https://ghc.haskell.org/trac/ghc/wiki/OverloadedLists

Thanks for the link, I've experimented a bit with this:

1) GHC will alert me if I use VIewPatterns and don't match _:

len (id -> []) = 0
len (id -> (_:xs)) = 1 + len xs

Warning:
    Pattern match(es) are non-exhaustive
    In an equation for ‘len’: Patterns not matched: _

I suppose this is because GHC cannot detect if "id" will yield bottom.

2) GHC, however, will alert me that I should also match [] if I use
OverloadedLists, as shown before. If I have correctly understood this
desugaring, it should warn me about matching _ as before.

I can't quite understand behaviour (2) there. Any ideas?

Nikolay.


More information about the Haskell-Cafe mailing list