Here-docs in Haskell source

Alistair Bayley alistair at
Fri Sep 22 16:15:49 EDT 2006

> > If you do this at all, reuse the regular quotes, don't invent yet
> > another weird and wonderful lexical syntax.  Haskell is already bad
> > enough that way, with \ used for lambda and so on.  @" would be okay I
> > guess.
> Why not just go the Python way and use """ ?
> That is, three literal quotes at the beginning and end.
> After all, Python has lifted quite a few things from Haskell.  Time to
> return the favor. ;-)

I'm not fussy as to exactly what syntax is chosen, just that we get
some kind of here-doc. I've been using C# quite a bit recently, so the
@"..." syntax seems quite appealing. It's fairly lightweight, and @
doesn't have too many other uses in Haskell syntax, does it? (just the
name@(a1:a2:_) usage springs to mind).

Something else to consider: in C#, at least, the escaping rules change
depending on which type of string literal you choose (single or
multi-line). In multi-line (AKA verbatim) strings, escaping is
switched off, so a single backslash, for example, will appear as such
in the output. This obviously makes it easier to preserve a block of
text verbatim if it contains backslashes and escape sequences. The
exceptions are backslash-double-quote (\") and two double-quotes (""),
which both result in one double-quote in the result.


More information about the Haskell-prime mailing list