[Haskell-cafe] Call for discussion: OverloadedLists extension

Roman Leshchinskiy rl at cse.unsw.edu.au
Mon Sep 24 17:50:45 CEST 2012


Michael Snoyman wrote:
>
> The simplest example I can think of is allowing easier usage of Vector:
>
>     [1, 2, 3] :: Vector Int
>
> In order to allow this, we could use a typeclass approach similar to
> how OverloadedStrings works:
>
>     class IsList a where
>         fromList :: [b] -> a b
>     instance IsList Vector where
>         fromList = V.fromList
>     foo :: Vector Int
>     foo = fromList [1, 2, 3]

I remember a similar discussion a few years ago. The question of whether
or not overloading list literals a good idea notwithstanding, the problem
with this is that fromList for vectors is highly inefficient. So if
something like this gets implemented and if vector/array literals are one
of the main motivations then I really hope there will be no lists
involved.

Roman






More information about the Haskell-Cafe mailing list