[Haskell-cafe] Call for discussion: OverloadedLists extension

Simon Peyton-Jones simonpj at microsoft.com
Mon Sep 24 19:19:07 CEST 2012


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

Would you like to remind us why it is so inefficient?  Can't the vector construction be a fold over the list?  Ah... you need to know the *length* of the list, don't you?  So that you can allocate a suitably-sized vector.  Which of course we do for literal lists.

So what if fromList went
	fromList :: Int -> [b] -> a b
where the Int is the length of the list?

Simon




More information about the Haskell-Cafe mailing list