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

2008-10-15 Thread Simon Marlow

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).


Cheers,
Simon
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2008-10-14 Thread Matt Morrow
 How exactly QuasiQuote behave, and what
 is available to handle them? (Or: can I
 find information already on the web?)

A QuasiQuoter is

data QuasiQuoter
  = QuasiQuoter {quoteExp :: String - Q Exp,
 quotePat :: String - Q Pat}
-- Defined in Language.Haskell.TH.Quote

There is a good writeup on the haskell.org wiki, and a link to a paper there.

 Sugestion: what about tex like syntax,
 i.e., change of line is a space, blank
 line is a newline (so that we could
 reformat the string without changing
 content)?

GHC hands you a String, and you can do arbitrary things
with it before you eventually return either an ExpQ or PatQ
(depending on context). I've uploaded a few QQs to hackage

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/regexqq
http://hackage.haskell.org/cgi-bin/hackage-scripts/package/lighttpd-conf-qq

and am working on both one for Haskell itself, as well as as for Javascript.

 Best,
 MaurĂ­cio

Matt
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


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

2008-10-13 Thread Mauricio

The new QuasiQuotes extension arriving with ghc 6.10 is very exciting,
and handling multi-line string literals is like stealing candy from
a baby. ;)

 (...)

Cool!!!

How exactly QuasiQuote behave, and what
is available to handle them? (Or: can I
find information already on the web?)

Sugestion: what about tex like syntax,
i.e., change of line is a space, blank
line is a newline (so that we could
reformat the string without changing
content)?

Best,
MaurĂ­cio

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe