static constants -- ideas?
jason.dusek at gmail.com
Sun Feb 24 02:56:25 EST 2008
I have an awkward programming problem -- I need to take a
dictionary, parse it, build a bunch of intermediate lists and
then make maps and tries out of the list. A "programming
problem" because it's taken me a fair amount of effort to pull
together the parser and list generator -- and "awkward"
because a 69000 item list, [(String, [(String, String)])],
does not compile under GHC (stack overflow). (It's not likely
to compile under anything else, either!)
Members of #haskell have urged me to load the offending
material from a file; indeed, it only takes ten seconds to
parse the dictionary and build the lists, sort them and dump
them back out again -- but it offends my sensibilities. I
don't want to wait ten seconds to load my dictionary every
I could use the FFI, then I can make the trie and lists all in
C. That'd work great. My list likely uses too much RAM now,
I'm considering one other option though -- I wonder if I can
build large constants in GHC Core? If anybody has tried it --
or found some other way to make big huge constants in Haskell
-- I would sure like to know about it.
On another note, I am extremely curious about the difference
between statically compiling a list and building it at
runtime. I find it hard to wrap my head around the fact that I
can build the list at runtime in a short time, but can not
compile it without eating all of my machine's RAM. Is it due
to laziness, maybe? Well, no -- because I subject the whole
list to a sort. It's not just streaming records in from one IO
handle and out another.
More information about the Glasgow-haskell-users