hpaco-lib 0.22.4.0 → 0.24.0.0
raw patch · 2 files changed
+13/−5 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Text.HPaco.Writers.Run: roOutput :: RunOptions -> Handle
+ Text.HPaco.Writers.Run: runWith :: ToVariant a => a -> RunOptions -> AST -> IO ()
- Text.HPaco.Writers.Run: RunOptions :: String -> RunOptions
+ Text.HPaco.Writers.Run: RunOptions :: String -> Handle -> RunOptions
Files
- Text/HPaco/Writers/Run.hs +12/−4
- hpaco-lib.cabal +1/−1
Text/HPaco/Writers/Run.hs view
@@ -1,6 +1,6 @@ {-#LANGUAGE ScopedTypeVariables #-} module Text.HPaco.Writers.Run- ( run+ ( run, runWith , RunState (..) , RunOptions (..) , defaultOptions@@ -12,6 +12,7 @@ import Prelude hiding (toInteger) import Data.Variant+import Data.Variant.ToFrom import qualified Data.Variant as V import Data.Maybe import Data.Monoid@@ -25,13 +26,16 @@ import Text.HPaco.AST.AST import Text.HPaco.AST.Statement import Text.HPaco.AST.Expression+import System.IO data RunOptions = RunOptions { roTemplateName :: String+ , roOutput :: Handle } defaultOptions = RunOptions { roTemplateName = "unnamed"+ , roOutput = stdout } data RunState = RunState@@ -43,8 +47,11 @@ type Run a = StateT RunState IO a run :: RunOptions -> AST -> IO ()-run opts ast = do- let st = RunState { rsScope = AList [], rsOptions = opts , rsAST = ast }+run = runWith $ AList []++runWith :: ToVariant a => a -> RunOptions -> AST -> IO ()+runWith scope opts ast = do+ let st = RunState { rsScope = toVariant scope, rsOptions = opts , rsAST = ast } execStateT (runAST ast) st return () @@ -61,7 +68,8 @@ runStatement :: Statement -> Run () runStatement (PrintStatement e) = do d <- runExpression e- liftIO . putStr . flatten $ d+ h <- gets (roOutput . rsOptions)+ liftIO . hPutStr h . flatten $ d runStatement (StatementSequence ss) = mapM_ runStatement ss runStatement (IfStatement cond true false) = do b <- liftM toBool $ runExpression cond
hpaco-lib.cabal view
@@ -1,5 +1,5 @@ name: hpaco-lib-version: 0.22.4.0+version: 0.24.0.0 synopsis: Modular template compiler library description: Template compiler library, compiles template code into PHP or Javascript, or interprets it directly.