From a672918c9407b7e6b1ff09a9804467ec0e3f94f0 Mon Sep 17 00:00:00 2001 From: remeike Date: Thu, 7 Nov 2024 12:05:25 -0500 Subject: [PATCH] Put ProcessContext state back into main state transformer --- src/Web/Larceny/Internal.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Web/Larceny/Internal.hs b/src/Web/Larceny/Internal.hs index f71cbe5..32b041a 100644 --- a/src/Web/Larceny/Internal.hs +++ b/src/Web/Larceny/Internal.hs @@ -7,7 +7,7 @@ module Web.Larceny.Internal ( findTemplate import Control.Exception import Lens.Micro import Control.Monad.Trans (liftIO) -import Control.Monad.State (MonadState, StateT, evalStateT, runStateT, get, modify) +import Control.Monad.State (MonadState, StateT, evalStateT, runStateT, get, put, modify) import qualified Data.HashSet as HS import qualified Data.Map as M import Data.Maybe (fromMaybe) @@ -111,7 +111,9 @@ toProcessState f = toUserState :: ProcessContext s -> StateT (ProcessContext s) IO a -> StateT s IO a toUserState pc f = do s <- get - liftIO $ evalStateT f (pc { _pcState = s }) + (result, pc') <- liftIO $ runStateT f (pc { _pcState = s }) + put (_pcState pc') + return result fillIn :: Blank -> Substitutions s -> Fill s fillIn tn m = fromMaybe (fallbackFill tn m) (M.lookup tn m) @@ -172,8 +174,6 @@ process (currentNode:nextNodes) = do return [t] NodeComment c -> return [""] - _ -> - return [] restOfNodes <- process nextNodes return $ processedNode ++ restOfNodes