interpolatedstring-perl6-0.1: QuasiQuoter for Perl6-style multi-line interpolated strings.Source codeContentsIndex

QuasiQuoter for interpolated strings using Perl 6 syntax.

The q form does one thing and does it well: It contains a multi-line string with no interpolation at all:

 import Text.InterpolatedString.Perl6 (q)
 foo :: String
 foo = [$q|

Well here is a
     multi-line string!


The qc form interpolates curly braces: Expressions inside {} will be directly interpolated if it's a String, or have show called if it is not.

Escaping of '{' is done with backslash.

For interpolating numeric expressions without an explicit type signature, use the ExtendedDefaultRules language pragma, as shown below:

 import Text.InterpolatedString.Perl6 (qc)
 bar :: String
 bar = [$qc| Well {"hello" ++ " there"} {6 * 7} |]

bar will have the value " Well hello there 42 ".

If you want control over how show works on your types, define a custom ShowQ instance:

 import Text.InterpolatedString.Perl6 (qc, ShowQ(..))
 instance ShowQ ByteString where
     showQ = unpack

That way you interpolate bytestrings will not result in double quotes or character escapes.

qc :: QuasiQuoter
q :: QuasiQuoter
class Show a => ShowQ a where
showQ :: a -> String
qc :: QuasiQuoterSource
QuasiQuoter for interpolating Haskell values into a string literal. The pattern portion is undefined.
q :: QuasiQuoterSource
class Show a => ShowQ a whereSource
showQ :: a -> StringSource
show/hide Instances
Produced by Haddock version 2.4.2