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  e5f372c117c20e06965fe51c5fdf1c74d770618a (commit)
       via  e208846cdae53d2fd86197e338a1a718ddc4a04f (commit)
      from  c992aad769f7f187b26787622b7d737c9ce75e0f (commit)


Summary of changes:
 src/Snap/Loader/Hint.hs |   23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 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 e5f372c117c20e06965fe51c5fdf1c74d770618a
Author: Carl Howells <[email protected]>
Date:   Fri Jun 25 00:52:15 2010 -0700

    make generation of the interpreted string safer and clearer

diff --git a/src/Snap/Loader/Hint.hs b/src/Snap/Loader/Hint.hs
index 656d29d..514f61d 100644
--- a/src/Snap/Loader/Hint.hs
+++ b/src/Snap/Loader/Hint.hs
@@ -42,13 +42,14 @@ loadSnapTH initialize cleanup action = do
         actMod = nameModule action
         actBase = nameBase action
 
-        str = concat [ "do { x <- liftIO "
-                     , initBase
-                     , "; "
-                     , actBase
-                     , " x; liftIO $ "
-                     , cleanBase
-                     , " x; }"
+        -- 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]
commit e208846cdae53d2fd86197e338a1a718ddc4a04f
Author: Carl Howells <[email protected]>
Date:   Fri Jun 25 00:51:31 2010 -0700

    Add a comment explaining a more oblique choice

diff --git a/src/Snap/Loader/Hint.hs b/src/Snap/Loader/Hint.hs
index bf87723..656d29d 100644
--- a/src/Snap/Loader/Hint.hs
+++ b/src/Snap/Loader/Hint.hs
@@ -31,8 +31,6 @@ import qualified Snap.Loader.Static as Static
 -- | XXX
 -- Assumes being spliced into the same source tree as the action to
 -- dynamically load is located in
--- Assumes mtl is the only package installed with a conflicting
--- Control.Monad.Trans
 loadSnapTH :: Name -> Name -> Name -> Q Exp
 loadSnapTH initialize cleanup action = do
     args <- runIO getArgs
@@ -64,6 +62,12 @@ loadSnapTH initialize cleanup action = do
 
     staticE <- Static.loadSnapTH initialize cleanup action
 
+    -- Wrap the hintSnap call in a let block.  This let block
+    -- vacuously pattern-matches the static expression, providing an
+    -- extra check that the types were correct at compile-time, at
+    -- 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]
         nameUnused = mkName "_"
         body = NormalB staticE
-----------------------------------------------------------------------


hooks/post-receive
-- 
snap
_______________________________________________
Snap mailing list
[email protected]
http://mailman-mail5.webfaction.com/listinfo/snap

Reply via email to