From be50798c9abc22648a0a3eb81db462abea79698c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 17 Dec 2013 16:47:03 +0000 Subject: [PATCH] remove TH --- Text/Coffee.hs | 56 ++++----------------------------------------- Text/Julius.hs | 67 +++++++++--------------------------------------------- Text/Roy.hs | 51 ++++------------------------------------- Text/TypeScript.hs | 51 ++++------------------------------------- 4 files changed, 24 insertions(+), 201 deletions(-) diff --git a/Text/Coffee.hs b/Text/Coffee.hs index 488c81b..61db85b 100644 --- a/Text/Coffee.hs +++ b/Text/Coffee.hs @@ -51,13 +51,13 @@ module Text.Coffee -- ** Template-Reading Functions -- | These QuasiQuoter and Template Haskell methods return values of -- type @'JavascriptUrl' url@. See the Yesod book for details. - coffee - , coffeeFile - , coffeeFileReload - , coffeeFileDebug + -- coffee + --, coffeeFile + --, coffeeFileReload + --, coffeeFileDebug #ifdef TEST_EXPORT - , coffeeSettings + --, coffeeSettings #endif ) where @@ -65,49 +65,3 @@ import Language.Haskell.TH.Quote (QuasiQuoter (..)) import Language.Haskell.TH.Syntax import Text.Shakespeare import Text.Julius - -coffeeSettings :: Q ShakespeareSettings -coffeeSettings = do - jsettings <- javascriptSettings - return $ jsettings { varChar = '%' - , preConversion = Just PreConvert { - preConvert = ReadProcess "coffee" ["-spb"] - , preEscapeIgnoreBalanced = "'\"`" -- don't insert backtacks for variable already inside strings or backticks. - , preEscapeIgnoreLine = "#" -- ignore commented lines - , wrapInsertion = Just WrapInsertion { - wrapInsertionIndent = Just " " - , wrapInsertionStartBegin = "(" - , wrapInsertionSeparator = ", " - , wrapInsertionStartClose = ") =>" - , wrapInsertionEnd = "" - , wrapInsertionAddParens = False - } - } - } - --- | Read inline, quasiquoted CoffeeScript. -coffee :: QuasiQuoter -coffee = QuasiQuoter { quoteExp = \s -> do - rs <- coffeeSettings - quoteExp (shakespeare rs) s - } - --- | Read in a CoffeeScript template file. This function reads the file once, at --- compile time. -coffeeFile :: FilePath -> Q Exp -coffeeFile fp = do - rs <- coffeeSettings - shakespeareFile rs fp - --- | Read in a CoffeeScript template file. This impure function uses --- unsafePerformIO to re-read the file on every call, allowing for rapid --- iteration. -coffeeFileReload :: FilePath -> Q Exp -coffeeFileReload fp = do - rs <- coffeeSettings - shakespeareFileReload rs fp - --- | Deprecated synonym for 'coffeeFileReload' -coffeeFileDebug :: FilePath -> Q Exp -coffeeFileDebug = coffeeFileReload -{-# DEPRECATED coffeeFileDebug "Please use coffeeFileReload instead." #-} diff --git a/Text/Julius.hs b/Text/Julius.hs index ec30690..5b5a075 100644 --- a/Text/Julius.hs +++ b/Text/Julius.hs @@ -14,17 +14,17 @@ module Text.Julius -- ** Template-Reading Functions -- | These QuasiQuoter and Template Haskell methods return values of -- type @'JavascriptUrl' url@. See the Yesod book for details. - js - , julius - , juliusFile - , jsFile - , juliusFileDebug - , jsFileDebug - , juliusFileReload - , jsFileReload + -- js + -- julius + -- juliusFile + -- jsFile + --, juliusFileDebug + --, jsFileDebug + --, juliusFileReload + --, jsFileReload -- * Datatypes - , JavascriptUrl + JavascriptUrl , Javascript (..) , RawJavascript (..) @@ -37,9 +37,9 @@ module Text.Julius , renderJavascriptUrl -- ** internal, used by 'Text.Coffee' - , javascriptSettings + --, javascriptSettings -- ** internal - , juliusUsedIdentifiers + --, juliusUsedIdentifiers , asJavascriptUrl ) where @@ -102,48 +102,3 @@ instance RawJS TL.Text where rawJS = RawJavascript . fromLazyText instance RawJS Builder where rawJS = RawJavascript instance RawJS Bool where rawJS = RawJavascript . unJavascript . toJavascript -javascriptSettings :: Q ShakespeareSettings -javascriptSettings = do - toJExp <- [|toJavascript|] - wrapExp <- [|Javascript|] - unWrapExp <- [|unJavascript|] - asJavascriptUrl' <- [|asJavascriptUrl|] - return $ defaultShakespeareSettings { toBuilder = toJExp - , wrap = wrapExp - , unwrap = unWrapExp - , modifyFinalValue = Just asJavascriptUrl' - } - -js, julius :: QuasiQuoter -js = QuasiQuoter { quoteExp = \s -> do - rs <- javascriptSettings - quoteExp (shakespeare rs) s - } - -julius = js - -jsFile, juliusFile :: FilePath -> Q Exp -jsFile fp = do - rs <- javascriptSettings - shakespeareFile rs fp - -juliusFile = jsFile - - -jsFileReload, juliusFileReload :: FilePath -> Q Exp -jsFileReload fp = do - rs <- javascriptSettings - shakespeareFileReload rs fp - -juliusFileReload = jsFileReload - -jsFileDebug, juliusFileDebug :: FilePath -> Q Exp -juliusFileDebug = jsFileReload -{-# DEPRECATED juliusFileDebug "Please use juliusFileReload instead." #-} -jsFileDebug = jsFileReload -{-# DEPRECATED jsFileDebug "Please use jsFileReload instead." #-} - --- | Determine which identifiers are used by the given template, useful for --- creating systems like yesod devel. -juliusUsedIdentifiers :: String -> [(Deref, VarType)] -juliusUsedIdentifiers = shakespeareUsedIdentifiers defaultShakespeareSettings diff --git a/Text/Roy.hs b/Text/Roy.hs index 8bffc5a..8bf2a09 100644 --- a/Text/Roy.hs +++ b/Text/Roy.hs @@ -39,12 +39,12 @@ module Text.Roy -- ** Template-Reading Functions -- | These QuasiQuoter and Template Haskell methods return values of -- type @'JavascriptUrl' url@. See the Yesod book for details. - roy - , royFile - , royFileReload + -- roy + --, royFile + --, royFileReload #ifdef TEST_EXPORT - , roySettings + --, roySettings #endif ) where @@ -53,46 +53,3 @@ import Language.Haskell.TH.Syntax import Text.Shakespeare import Text.Julius --- | The Roy language compiles down to Javascript. --- We do this compilation once at compile time to avoid needing to do it during the request. --- We call this a preConversion because other shakespeare modules like Lucius use Haskell to compile during the request instead rather than a system call. -roySettings :: Q ShakespeareSettings -roySettings = do - jsettings <- javascriptSettings - return $ jsettings { varChar = '#' - , preConversion = Just PreConvert { - preConvert = ReadProcess "roy" ["--stdio", "--browser"] - , preEscapeIgnoreBalanced = "'\"" - , preEscapeIgnoreLine = "//" - , wrapInsertion = Just WrapInsertion { - wrapInsertionIndent = Just " " - , wrapInsertionStartBegin = "(\\" - , wrapInsertionSeparator = " " - , wrapInsertionStartClose = " ->\n" - , wrapInsertionEnd = ")" - , wrapInsertionAddParens = True - } - } - } - --- | Read inline, quasiquoted Roy. -roy :: QuasiQuoter -roy = QuasiQuoter { quoteExp = \s -> do - rs <- roySettings - quoteExp (shakespeare rs) s - } - --- | Read in a Roy template file. This function reads the file once, at --- compile time. -royFile :: FilePath -> Q Exp -royFile fp = do - rs <- roySettings - shakespeareFile rs fp - --- | Read in a Roy template file. This impure function uses --- unsafePerformIO to re-read the file on every call, allowing for rapid --- iteration. -royFileReload :: FilePath -> Q Exp -royFileReload fp = do - rs <- roySettings - shakespeareFileReload rs fp diff --git a/Text/TypeScript.hs b/Text/TypeScript.hs index 70c8820..5be994a 100644 --- a/Text/TypeScript.hs +++ b/Text/TypeScript.hs @@ -57,12 +57,12 @@ module Text.TypeScript -- ** Template-Reading Functions -- | These QuasiQuoter and Template Haskell methods return values of -- type @'JavascriptUrl' url@. See the Yesod book for details. - tsc - , typeScriptFile - , typeScriptFileReload + -- tsc + --, typeScriptFile + --, typeScriptFileReload #ifdef TEST_EXPORT - , typeScriptSettings + --, typeScriptSettings #endif ) where @@ -71,46 +71,3 @@ import Language.Haskell.TH.Syntax import Text.Shakespeare import Text.Julius --- | The TypeScript language compiles down to Javascript. --- We do this compilation once at compile time to avoid needing to do it during the request. --- We call this a preConversion because other shakespeare modules like Lucius use Haskell to compile during the request instead rather than a system call. -typeScriptSettings :: Q ShakespeareSettings -typeScriptSettings = do - jsettings <- javascriptSettings - return $ jsettings { varChar = '#' - , preConversion = Just PreConvert { - preConvert = ReadProcess "sh" ["-c", "TMP_IN=$(mktemp XXXXXXXXXX.ts); TMP_OUT=$(mktemp XXXXXXXXXX.js); cat /dev/stdin > ${TMP_IN} && tsc --out ${TMP_OUT} ${TMP_IN} && cat ${TMP_OUT}; rm ${TMP_IN} && rm ${TMP_OUT}"] - , preEscapeIgnoreBalanced = "'\"" - , preEscapeIgnoreLine = "//" - , wrapInsertion = Just WrapInsertion { - wrapInsertionIndent = Nothing - , wrapInsertionStartBegin = ";(function(" - , wrapInsertionSeparator = ", " - , wrapInsertionStartClose = "){" - , wrapInsertionEnd = "})" - , wrapInsertionAddParens = False - } - } - } - --- | Read inline, quasiquoted TypeScript -tsc :: QuasiQuoter -tsc = QuasiQuoter { quoteExp = \s -> do - rs <- typeScriptSettings - quoteExp (shakespeare rs) s - } - --- | Read in a TypeScript template file. This function reads the file once, at --- compile time. -typeScriptFile :: FilePath -> Q Exp -typeScriptFile fp = do - rs <- typeScriptSettings - shakespeareFile rs fp - --- | Read in a Roy template file. This impure function uses --- unsafePerformIO to re-read the file on every call, allowing for rapid --- iteration. -typeScriptFileReload :: FilePath -> Q Exp -typeScriptFileReload fp = do - rs <- typeScriptSettings - shakespeareFileReload rs fp -- 1.8.5.1