Ticket #158: Quasi.hs

File Quasi.hs, 417 bytes (added by arcatan, 4 years ago)

A trivial quasiquoter

Line 
1{-# LANGUAGE DeriveDataTypeable #-}
2module Quasi (qq, Var (..)) where
3
4import Data.Generics
5import qualified Language.Haskell.TH as TH
6import Language.Haskell.TH.Quote
7
8data Var = Var String deriving (Data, Typeable, Show)
9
10qq :: QuasiQuoter
11qq = QuasiQuoter qqExp qqPat
12
13qqExp :: String -> TH.ExpQ
14qqExp s = dataToExpQ (const Nothing) (Var s)
15
16qqPat :: String -> TH.PatQ
17qqPat s = dataToPatQ (const Nothing) (Var s)