On Mon, Sep 24, 2012 at 5:53 AM, George Giorgidze <giorgidze at gmail.com>wrote:
> Our second approach to OverloadedLists is to avoid the construction of
> lists altogether. By typechecking and desugaring lists like
>> [] ; [x,y,z] ; ['a' .. 'z'] ;
>> as
>> mempty ; singleton x `mappend` singleton y `mappend` singleton z ;
> genericEnumFromTo 'a' 'z' ;
>
This is very interesting.
As Michael mentions later, we already have mechanisms in place to work
around the creation of constant strings for the Text and ByteString types,
and they rely on a combination of GHC rewrite rules and knowledge about the
internal representation of constant strings used by GHC. We are fortunate
that GHC uses a very efficient representation to store constant strings, so
doing the translation is efficient.
Constant lists are another story entirely (for good reason); the generated
object files are bloated and poorly laid out, when for simple types
(integers and whatnot), I'd really like to see a packed array in the .data
section.
I would be interested to see if an approach that avoids list construction
can also aim to achieve a more efficient object file layout, with the
implied goal being to make fast translation to the runtime representation
easily achievable.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120925/ea71b086/attachment.htm>