{-# LANGUAGE FlexibleInstances #-}
module PyF
( fmt,
fmtWithDelimiters,
module PyF.Class,
)
where
import Language.Haskell.TH.Quote (QuasiQuoter (..))
import PyF.Class
import PyF.Internal.QQ (toExp)
templateF :: (Char, Char) -> String -> QuasiQuoter
templateF delimiters fName =
QuasiQuoter
{ quoteExp = toExp delimiters,
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 = ('{', '}')