backslashes within quotes

Lennart Augustsson lennart at
Fri Oct 5 17:01:35 CEST 2012

I agree that backslash string wrapping is obscure.
I do use it a lot, but I would not be sad to see it go.

The same is true for \a, \b, \f, \v, \EM, \DC1, etc.
We do need \&, though.

On Tue, Oct 2, 2012 at 10:17 PM, Evan Laforge <qdunkan at> wrote:

> The backslash string wrapping feature is a fairly obscure part of
> haskell syntax, and some tools don't handle it properly (e.g. the
> built in 'lex' function won't lex such strings properly).  It's also
> not as useful as e.g. python's triple quotes, because you have to
> suffix and prefix every line with a backslash.  As long as you are
> have to add suffixes and prefixes (i.e. straight cut and paste no
> longer works), you might as well write it out with (++).  In other
> words, as long as you're applying ('\\':) . (++"\\") you might as well
> apply ("++ \""++) . (++"\"").  And it seems to me that "string
> literal" ++ "another string" is an easy thing for a compiler to
> optimize, ghc-core says ghc unsurprisingly has no trouble with it.
> So it's probably not helpful for performance.  IMO it's not very
> useful for it's intended purpose (embedding multiline strings) because
> of the \s everywhere.  It doesn't seem very widely used, and it adds a
> little bit of a hassle to parsing.  And 'lex' doesn't support it.
> Any interest in getting rid of it?
> I would actually be in favor of triple quotes (yeah, I know it can be
> done with quasi-quotes, but still...), but that's a different issue.
> Also, it's hardly a big deal, but do we really need \a, \b, \f, and
> \v?  The one time I used one (it was \v) it was a typo and I would
> have preferred the parse error, instead I got weird output that I
> didn't notice for a long time.  If I really want to, say, ring the
> terminal bell or do a vertical tab or perhaps send a telegraph, I
> would be using some library that handles terminal type stuff in a
> higher level way.  Similarly, the \EM, \DC1, etc. codes are probably
> not pulling their weight.  The '70s were 40 years ago!  And there's
> that weird \& thing.  Surely cursor control library authors have
> better ways to construct their magic codes.
> _______________________________________________
> Haskell-prime mailing list
> Haskell-prime at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Haskell-prime mailing list