[Haskell-cafe] Re: Multi-line string literals are both easy /and/elegant in Haskell

Simon Marlow marlowsd at gmail.com
Wed Oct 15 05:21:14 EDT 2008

Don Stewart wrote:
> mjm2002:
>> On 10/13/08, Andrew Coppin wrote:
>>> Cool. Is there any progress on getting GHC to *not* freak out when you
>>> ask it to compile a CAF containing several hundred KB of string literal? :-}
>> Yes and no. There's dons' compiled-constants pkg which has a solution:
>>   http://code.haskell.org/~dons/code/compiled-constants/
>> And the code below would do all the haskell-side work for importing
>> the data from C, but I'm not aware of a way to have ghc not freak out
>> if it has to compile a huge amount of static data.
> Hiding  it inside an unboxed string constant?
> i.e.    
>     "this be bits"#
> Or does GHC still freak?

This is the trick I use in Haddock and Alex, it should work fine.  I don't 
know why GHC should have any problems with larger string literals anyway, 
since they get compiled into

x = unpackCString "..."#

if you have evidence to the contrary, please submit a bug report.  (lists 
of other things are a different matter, which we already have open bugs for).


More information about the Haskell-Cafe mailing list