{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -fno-warn-missing-fields #-}
module Text.Roy
(
roy
, royFile
, royFileReload
#ifdef TEST_EXPORT
, roySettings
#endif
) where
import Language.Haskell.TH.Quote (QuasiQuoter (..))
import Language.Haskell.TH.Syntax
import Text.Shakespeare
import Text.Julius
roySettings :: Q ShakespeareSettings
roySettings :: Q ShakespeareSettings
roySettings = do
ShakespeareSettings
jsettings <- Q ShakespeareSettings
javascriptSettings
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ ShakespeareSettings
jsettings { varChar :: Char
varChar = Char
'#'
, preConversion :: Maybe PreConvert
preConversion = forall a. a -> Maybe a
Just PreConvert {
preConvert :: PreConversion
preConvert = String -> [String] -> PreConversion
ReadProcess String
"roy" [String
"--stdio", String
"--browser"]
, preEscapeIgnoreBalanced :: String
preEscapeIgnoreBalanced = String
"'\""
, preEscapeIgnoreLine :: String
preEscapeIgnoreLine = String
"//"
, wrapInsertion :: Maybe WrapInsertion
wrapInsertion = forall a. a -> Maybe a
Just WrapInsertion {
wrapInsertionIndent :: Maybe String
wrapInsertionIndent = forall a. a -> Maybe a
Just String
" "
, wrapInsertionStartBegin :: String
wrapInsertionStartBegin = String
"(\\"
, wrapInsertionSeparator :: String
wrapInsertionSeparator = String
" "
, wrapInsertionStartClose :: String
wrapInsertionStartClose = String
" ->\n"
, wrapInsertionEnd :: String
wrapInsertionEnd = String
")"
, wrapInsertionAddParens :: Bool
wrapInsertionAddParens = Bool
True
}
}
}
roy :: QuasiQuoter
roy :: QuasiQuoter
roy = QuasiQuoter { quoteExp :: String -> Q Exp
quoteExp = \String
s -> do
ShakespeareSettings
rs <- Q ShakespeareSettings
roySettings
QuasiQuoter -> String -> Q Exp
quoteExp (ShakespeareSettings -> QuasiQuoter
shakespeare ShakespeareSettings
rs) String
s
}
royFile :: FilePath -> Q Exp
royFile :: String -> Q Exp
royFile String
fp = do
ShakespeareSettings
rs <- Q ShakespeareSettings
roySettings
ShakespeareSettings -> String -> Q Exp
shakespeareFile ShakespeareSettings
rs String
fp
royFileReload :: FilePath -> Q Exp
royFileReload :: String -> Q Exp
royFileReload String
fp = do
ShakespeareSettings
rs <- Q ShakespeareSettings
roySettings
ShakespeareSettings -> String -> Q Exp
shakespeareFileReload ShakespeareSettings
rs String
fp