-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Store Larceny state in monad transformer stack #61
base: master
Are you sure you want to change the base?
Conversation
The mk field isn't necessary because it's always just the mk function.
No longer used by LarcenyState Move LarcenyM to Types
Ideally, the legacy module will allow apps to continue using existing Fills just by importing Web.Larceny.Legacy instead of Web.Larceny.Fills.
1c49014
to
e308389
Compare
@@ -182,8 +182,8 @@ fillChildrenWith' m = maybeFillChildrenWith' (Just <$> m) | |||
-- > Bonnie Thunders | |||
maybeFillChildrenWith :: Maybe (Substitutions s) -> Fill s | |||
maybeFillChildrenWith Nothing = textFill "" | |||
maybeFillChildrenWith (Just s) = Fill $ \_s (pth, Template tpl) l -> | |||
tpl pth s l | |||
maybeFillChildrenWith (Just s) = Fill $ \_attrs tpl -> do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove do
@@ -124,17 +124,17 @@ rawTextFill' t = Fill $ \_m _t _l -> t | |||
mapSubs :: (a -> Substitutions s) | |||
-> [a] | |||
-> Fill s | |||
mapSubs f xs = Fill $ \_attrs (pth, tpl) lib -> | |||
T.concat <$> mapM (\n -> runTemplate tpl pth (f n) lib) xs | |||
mapSubs f xs = Fill $ \_attrs tpl -> do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove do
liftIO $ evalStateT f (pc { _pcState = s }) | ||
Template $ \m -> | ||
do modify (lSubs .~ m) | ||
-- lPath .= pth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be set?
Fill $ \attr tpl -> | ||
do st <- get | ||
let pth = _lPath st | ||
liftIO $ putStrLn ("Larceny: Missing fill for blank " <> show tn <> " in template " <> show pth) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start using the logger.
|
||
process :: [Node] -> ProcessT s | ||
process :: [Node] -> LarcenyM s [Text] | ||
process [] = return [] | ||
process (NodeElement (BindElement atr kids):nextNodes) = do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove do
processBlank tagName atr kids = do | ||
(ProcessContext pth m l _ mko _ _) <- get | ||
m <- _lSubs <$> get |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't call this m
filled <- fillAttrs atr | ||
sequence [ toProcessState $ unFill (fillIn (Blank tagName) m) | ||
sequence [ unFill (fillIn (Blank tagName) m) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sequence
?
[Node] -> | ||
LarcenyM s [Text] | ||
processBind atr kids nextNodes = do | ||
m <- _lSubs <$> get |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another m
@@ -0,0 +1,92 @@ | |||
{-# LANGUAGE OverloadedStrings #-} | |||
|
|||
module Web.Larceny.Legacy ( textFill |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is going to be useful, need to go through and make the types the same.
let incrementSub = | ||
subs [("increment-and-print", | ||
Fill $ \_ _ -> | ||
do -- eek refactor later |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove or make it a real TODO
No description provided.