[Haskell-cafe] Split the IsList class for OverloadedLists

Henning Thielemann lemming at henning-thielemann.de
Sat Oct 31 19:55:02 UTC 2020

On Sat, 31 Oct 2020, Olaf Klinke wrote:

>> (Note: we can't just replace ToList with Foldable, because these 
>> classes have different kinds.)
>> - Any objections? An obvious concern is backwards compatibility. Is 
>> that a deal breaker? Are there other issues with this idea?

> You would lose the pattern matching functionality, it seems. 
> It reminds me very much of OverloadedStrings and that is not always as
> convenient as you might think. The issue is that a previously
> monomorphic piece of syntax suddenly is polymorphic, so in some places
> with OveroadedStrings one must provide type annotations. And that
> destroys the brevity one was after.

That's the problem.

Instead of extending syntactic sugar you can resort to plain functional 
programming. Constructing a list:

    l :: [a] -> YourList a

Use like:


Matching a list using continuation passing:

    withList :: ([a] -> b) -> YourList a -> b

Use like in:

    func m = withList $ \(x:y:_) n -> ...

More information about the Haskell-Cafe mailing list