[Haskell-beginners] Large tables and GHC.

Stephen Tetley stephen.tetley at gmail.com
Thu Dec 17 04:05:51 EST 2009

Hi Sherard

You could use Data.Array.IO to read the data at runtime. Its not ideal
as as well as moving the array read to runtime (the data file must be
present somewhere) it puts you in the IO monad...

I'm supposing you really want the equivalent of the C idiom where
bitmaps or whatever are stored as char or byte arrays:

const char bitmap1[] = { 0xFF, ... }

GHC has array literals between #'s, here is a snippet from code
generate by Alex, the lexer generator:

data AlexAddr = AlexA# Addr#

alex_deflt :: AlexAddr
alex_deflt = AlexA# "\xff\xff\xff\xff\xff\xff\xff\xff"#

Unfortunately I can't seem to find mention of array literals in the
GHC user guide only the related 'Magic Hash' and I've never used array
literals directly myself - only with code generated by Alex, so I
can't really say how they work. Hopefully someone will add a better
explanation soon.

Best wishes


2009/12/17 Sherard D. <scdames at gmail.com>:
> Hi,

> I have a couple of rather large byte tables that I'd like to use. I decided
> to use them as arrays because I figured such large tables wouldn't work well
> as lists.

More information about the Beginners mailing list