This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "snap".
The branch, master has been updated
via 52c0a132ed79c090b1176d18d2e9f601f390cc65 (commit)
from a3245abc320f1990181d079d140a1aee5436fc6b (commit)
Summary of changes:
TODO | 7 -------
src/Snap/Loader/Hint.hs | 37 ++++++++++++++-----------------------
2 files changed, 14 insertions(+), 30 deletions(-)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 52c0a132ed79c090b1176d18d2e9f601f390cc65
Author: Carl Howells <[email protected]>
Date: Sun Jun 27 10:30:36 2010 -0700
Minor refactoring of Snap.Loader.Hint, and handle errors better within it.
diff --git a/TODO b/TODO
index 5a46e0f..815bf69 100644
--- a/TODO
+++ b/TODO
@@ -3,13 +3,6 @@ TODO
Move Server out of the template projects into snap-server
-Need to handle various "failure" cases in the eval'd hint code.
- -- looking at cases that specifically prevent the cleanup action
- from being run in the current code.
- -- exceptions
- -- Left return value
- -- Nothing return value
-
Handle local persistent state.
-- Or not? Rails gets by just fine without local persistent state.
-- I'm leaning towards "not", until someone can explain why it's a real
diff --git a/src/Snap/Loader/Hint.hs b/src/Snap/Loader/Hint.hs
index 514f61d..b204c47 100644
--- a/src/Snap/Loader/Hint.hs
+++ b/src/Snap/Loader/Hint.hs
@@ -42,24 +42,14 @@ loadSnapTH initialize cleanup action = do
actMod = nameModule action
actBase = nameBase action
- -- this is safe because 3 unknowns can't match 4 options
- varName = head . dropWhile (`elem` [initBase, cleanBase, actBase])
- $ [ "a", "b", "c", "d" ]
-
- -- run init. run the handler. clean up.
- str = concat [ "do { " , varName , " <- liftIO " , initBase , "; "
- , actBase , " " , varName ,"; "
- , "liftIO $ " , cleanBase , " " , varName , "; }"
- ]
-
modules = catMaybes [initMod, cleanMod, actMod]
opts = getHintOpts args
- hintSnapE <- [| \o m s -> fmap ((,) $ return ()) $ hintSnap o m s |]
+ hintSnapE <- [| \o m i c a ->
+ fmap ((,) $ return ()) $ hintSnap o m i c a |]
- optsE <- lift opts
- modulesE <- lift modules
- strE <- lift str
+ [ optsE, modulesE ] <- mapM lift [ opts, modules ]
+ [ initE, cleanE, actE ] <- mapM lift [ initBase, cleanBase, actBase ]
staticE <- Static.loadSnapTH initialize cleanup action
@@ -69,7 +59,7 @@ loadSnapTH initialize cleanup action = do
-- least. This check isn't infallible, because the type isn't
-- fully specified, but it's an extra level of help with
-- negligible compile-time cost.
- let hintApp = foldl AppE hintSnapE [optsE, modulesE, strE]
+ let hintApp = foldl AppE hintSnapE [optsE, modulesE, initE, cleanE, actE]
nameUnused = mkName "_"
body = NormalB staticE
clause = Clause [] body []
@@ -97,14 +87,15 @@ getHintOpts args = "-hide-package=mtl" : filter (not .
(`elem` bad)) opts
------------------------------------------------------------------------------
-- | XXX
-hintSnap :: [String] -> [String] -> String -> IO (Snap ())
-hintSnap opts mNames action = do
- let interpreter = do
- mapM_ unsafeSetGhcOption opts
- loadModules . nub $ mNames
- let allMods = "Prelude":"Snap.Types":"Control.Monad.Trans":mNames
- setImports . nub $ allMods
- interpret action (as :: Snap ())
+hintSnap :: [String] -> [String] -> String -> String -> String -> IO (Snap ())
+hintSnap opts mNames initBase cleanBase actBase = do
+ let action = intercalate " " ["bracketSnap", initBase, cleanBase, actBase]
+ interpreter = do
+ mapM_ unsafeSetGhcOption opts
+ loadModules . nub $ mNames
+ let allMods = "Prelude" : "Snap.Types" : mNames
+ setImports . nub $ allMods
+ interpret action (as :: Snap ())
loadAction <- protectedActionEvaluator 3 $ runInterpreter interpreter
-----------------------------------------------------------------------
hooks/post-receive
--
snap
_______________________________________________
Snap mailing list
[email protected]
http://mailman-mail5.webfaction.com/listinfo/snap