
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. table1 = listArray (0, 25599) [...] table2 = listArray (0, 25599) [...] This is how my code looks, minus the large tables. However, the problem is that the large tables are loaded as a list first, and then converted to an array. This is indeed a very big problem, as trying to compile with GHC takes an unacceptably long time. Is there any way I can get around this? - Sherard

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
Stephen
2009/12/17 Sherard D.
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.

Hi,
On Wed, Dec 16, 2009 at 11:05 PM, Sherard D.
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.
table1 = listArray (0, 25599) [...] table2 = listArray (0, 25599) [...]
This is how my code looks, minus the large tables. However, the problem is that the large tables are loaded as a list first, and then converted to an array. This is indeed a very big problem, as trying to compile with GHC takes an unacceptably long time.
If compilating time is only an issue while developping, maybe you can put your tables in a separate module? That way they only get compiled once (or when you change them) and they don't get recompiled when you change the rest of your program. Patrick
Is there any way I can get around this?
- Sherard _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
-- ===================== Patrick LeBoutillier Rosemère, Québec, Canada
participants (3)
-
Patrick LeBoutillier
-
Sherard D.
-
Stephen Tetley