These expressions
(named after similar things in Unix shells)
are another way of writing string literals, often useful for large strings.
Everything from `` to ''
(including newlines and backslashes, but not $ characters)
is treated as literal text, and layout is ignored.
The exception is the $ character,
so that you can embed the value of the variable var
in the string by writing
$(var).
To get a literal $ character,
write $$ —
single $ characters are not allowed.
When the
+H option
is given, the following
letter name = ``Dear $(name),
Here are some characters: \ ' ` ".
To learn more, send $$10 to the address below.'' |
is equivalent the Haskell 98 declaration
letter name = "Dear " ++ quote name ++ ",\n\
\Here are some characters: \\ ' ` \".\n\
\To learn more, send $10 to the address below." |
The function
class Quote where
quote :: a -> String |
(basically no change for
String and
Char,
and
show for everything else)
comes from the
Hugs.Quote module,
which also defines several common instances,
and should be imported if you use the
$(var) form.
(This module also requires the
-98 option.)