
jason.dusek:
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 time.
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, anyways.
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.
You can build large constant bytestrings, fwiw. They turn into an Addr#, and GHC will leave them alone. See, e.g. this regex testsuite, which has *lots* of bytestring (overloaded) literals, http://code.haskell.org/~dons/code/pcre-light/tests/Unit.hs Using the OverloadedStrings pragma. This is approximately the same approach as Alex (the lexer generator) takes with its lexing tables stored in an unboxed string literal. -- Don