[Haskell-cafe] Warnings with OverloadedLists

Ozgur Akgun ozgurakgun at gmail.com
Tue Jun 17 21:46:04 UTC 2014


Hi Nikolay,

On 16 June 2014 18:19, Nikolay Amiantov <nikoamia at gmail.com> wrote:

> 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.
>

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

As a workaround, you could try calling `toList` explicitly in a case
statement to implement a `len` function for types with an IsList instance.
Maybe something like the following.

len :: IsList l => l -> Int
len xs = case toList xs of [] -> ...

Or even:

len :: IsList l => l -> Int
len = length . toList

Hope this helps.

-- 
Ozgur Akgun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140618/9d76efab/attachment.html>


More information about the Haskell-Cafe mailing list