[Haskell] Compilation of big, static tables

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Thu Feb 23 05:40:31 EST 2006


Stefan Karrmann <S.Karrmann at web.de> wrote:

> can ghc compile huge tables into efficient code if they are constant
> at compile time?

I have a related but different question.  If I have large, statically
defined tables of data e.g.

    table = listArray (0,max) [ [1,2,3,4]
                              , [5,6,7,8,9,10]
                              , [11,12,13]
                              ...
                              ]

i.e. no computation is required, can these be compiled directly to a
space-efficient lookup structure?  Compilers might do something
reasonable for large static strings of chars, but they cannot do the
same for arrays.  The trouble is that the Array types are abstract, so
one cannot use the natural literal constructor.

What I would really like is a syntax to statically construct an array,
without having to compute it from a list.  I'm not sure that even
Template Haskell can help here, since there is no normal form for it to
translate to.

Regards,
    Malcolm


More information about the Haskell mailing list