File: QQ.hs

package info (click to toggle)
haskell-regex 1.1.0.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 424 kB
  • sloc: haskell: 4,533; makefile: 3
file content (29 lines) | stat: -rw-r--r-- 922 bytes parent folder | download | duplicates (2)
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
{-# LANGUAGE DeriveDataTypeable         #-}

module Text.RE.ZeInternals.QQ where

import           Control.Exception
import           Data.Typeable
import           Language.Haskell.TH.Quote


-- | used to throw an exception reporting an abuse of a quasi quoter
data QQFailure =
  QQFailure
    { _qqf_context   :: String  -- ^ in what context was the quasi quoter used
    , _qqf_component :: String  -- ^ how was the quasi quoter being abused
    }
  deriving (Show,Typeable)

instance Exception QQFailure where

-- | a quasi quoter that can be used in no context (to be extended with
-- the appropriate quasi quoter parser)
qq0 :: String -> QuasiQuoter
qq0 ctx =
  QuasiQuoter
    { quoteExp  = const $ throw $ QQFailure ctx "expression"
    , quotePat  = const $ throw $ QQFailure ctx "pattern"
    , quoteType = const $ throw $ QQFailure ctx "type"
    , quoteDec  = const $ throw $ QQFailure ctx "declaration"
    }