
On Fri, Jan 1, 2010 at 7:09 AM, Tom Hawkins
I have a large tarball I want to link into an executable as a ByteString. What is the best way to do this? I can convert the tarball into a haskell file, but I'm afraid ghc would take a long time to compile it. Is there any way to link constant data directly with ghc? If not, what's the most efficient way to code large ByteStrings for fast compilation?
Possibly the simplest is to use unsafePackAddress or unsafePackAddressLen: {-# LANGUAGE MagicHash #-} module Const where import Data.ByteString.Unsafe as U import System.IO.Unsafe my_bstr = unsafePerformIO $ U.unsafePackAddress "abcdefg"# This trick of embedding raw strings (of type Addr#) is how happy and alex store their parser lookup tables in the modules they generate. I haven't seen any performance issues with it myself. Hope that helps, -Judah