blob: 7efe692b79f93a65afdfaf711185781428205a5e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
{-# LANGUAGE TemplateHaskell #-}
-- | QuasiQuoter for non-interpolated strings, texts and bytestrings.
--
-- Originally by Audrey Tang <audreyt@audreyt.org>
--
-- The "s" quoter contains a multi-line string with no interpolation at all:
--
-- @
-- {-\# LANGUAGE QuasiQuotes #-}
-- import Data.Text (Text)
-- import Data.String.Quote
-- foo :: Text -- "String", "ByteString" etc also works
-- foo = [s|
--
-- Well here is a
-- multi-line string!
--
-- |]
-- @
--
-- Any instance of the IsString type is permitted.
module Data.String.Quote (s) where
import Alpha
import GHC.Exts (IsString (..))
import qualified Language.Haskell.TH as TH
import Language.Haskell.TH.Quote
-- | QuasiQuoter for a non-interpolating IsString literal. The pattern portion is undefined.
s :: QuasiQuoter
s =
QuasiQuoter
((\a -> [|fromString a|]) <. filter (/= '\r'))
(error "Cannot use q as a pattern")
(error "Cannot use q as a type")
(error "Cannot use q as a dec")
|