syntax...(strings/interpolation/here docs)

Jeffrey R Lewis jeff@galois.com
Wed, 13 Feb 2002 08:42:09 -0800


On Wednesday 13 February 2002 06:36 am, C.Reinke wrote:
> > > Does anybody with their elbows in the
> > > code think variable interpolation and/or
> > > multi-line strings are good/doable ideas?
> > > Would this be the sort of change one could make
> > > without a lot of previous familiarity with
> > > the implementation of Hugs/Ghc?
>
> Unlike my rough proposal, one should aim for a combination of
> (mostly) in-Haskell implementation and (some) pre-processing.  As
> Thomas Nordin has pointed out to me in private email, Hugs (Dec
> 2001) already supports this (module lib/hugs/Quote.hs and flag +H).
>
> The real trick is to have the same support in all implementations..

I use here docs quite a bit.  They are wonderful for writing error messages 
that are also readable in the code ;-)

The point about same support in all implementations is of course a good one.  
Thomas and I are the culprits who put here docs in hugs in the first place.  
However, it is just as easy to support here docs using a pre-processor.  I 
have a medium sized project that uses here docs, and can be used under both 
hugs and ghc.  With hugs, I use the builtin feature, of course.  With GHC, we 
just use a pre-processor.  This is a bit awkward with GHC 5.02 and earlier 
versions, but starting with 5.03, GHC now has a proper interface for hooking 
in a pre-processor (don't know the details, bug Sigbjorn says it's in there). 
 A convenient feature of here docs that makes it easy to implement as a 
pre-processor is that you can do the unhere doc translation so that it 
preserves line numbers.  The only drawback to using a pre-processor is that 
it probably won't work with ghci (but then you probably don't need to write 
here docs at the command line either!).

--Jeff