{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeApplications #-}
module PyF
( fmt
, fmtWithDelimiters
, module PyF.Class
)
where
import Language.Haskell.TH.Quote (QuasiQuoter(..))
import PyF.Internal.QQ (toExp)
import PyF.Class
templateF :: (Char, Char) -> String -> QuasiQuoter
templateF delimiters fName = QuasiQuoter {
quoteExp = \s -> (toExp delimiters s)
, quotePat = err "pattern"
, quoteType = err "type"
, quoteDec = err "declaration"
}
where
err name = error (fName ++ ": This QuasiQuoter can not be used as a " ++ name ++ "!")
fmt :: QuasiQuoter
fmt = templateF pythonDelimiters "fmt"
fmtWithDelimiters :: (Char, Char) -> QuasiQuoter
fmtWithDelimiters delimiters = templateF delimiters "fmtWithDelimiters"
pythonDelimiters :: (Char, Char)
pythonDelimiters = ('{', '}')