aboutsummaryrefslogtreecommitdiff
path: root/hypsrc-test/src/Quasiquoter.hs
blob: 48f1b155efad2d35c12d2b0246d3be590a117f90 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{-# LANGUAGE Haskell2010 #-}
module Quasiquoter ( string ) where

import Language.Haskell.TH.Quote
import Language.Haskell.TH.Syntax

-- | Quoter for constructing multiline string literals
string :: QuasiQuoter
string = QuasiQuoter
  { quoteExp = pure . LitE . StringL
  , quotePat = invalidDomain
  , quoteType = invalidDomain
  , quoteDec = invalidDomain
  }
  where
    invalidDomain :: String -> Q a
    invalidDomain _ = fail "stringQuoter: only valid in expression context"