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  8937d0e9c5dd0a04f9eaf48a047dcfcebc53fddf (commit)
      from  46f3719f6be6acdc8ce5c57c305bea562d806cfc (commit)


Summary of changes:
 project_template/hint/src/Main.hs |   31 +++++++++++++++++++++++++------
 1 files changed, 25 insertions(+), 6 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 8937d0e9c5dd0a04f9eaf48a047dcfcebc53fddf
Author: Carl Howells <[email protected]>
Date:   Wed Jun 30 15:45:05 2010 -0700

    Prettify and document the hint template Main.hs

diff --git a/project_template/hint/src/Main.hs 
b/project_template/hint/src/Main.hs
index 939bfa6..a8f7b38 100644
--- a/project_template/hint/src/Main.hs
+++ b/project_template/hint/src/Main.hs
@@ -1,10 +1,10 @@
 {-# LANGUAGE CPP, TemplateHaskell #-}
 module Main where
 
-import Data.Monoid (mappend, mempty)
+import Data.Monoid        (mappend, mempty)
 
-import Config (getConfig, cleanupConfig)
-import Site (site)
+import Config             (getConfig, cleanupConfig)
+import Site               (site)
 
 import Snap.Http.Server
 import Snap.Http.Server.Config
@@ -12,20 +12,39 @@ import Snap.Http.Server.Config
 #ifdef PRODUCTION
 import Snap.Loader.Static (loadSnapTH)
 #else
-import Snap.Loader.Hint (loadSnapTH)
+import Snap.Loader.Hint   (loadSnapTH)
 #endif
 
+-- This is the entry point for this web server application.  It
+-- supports easily switching between interpreting source and running
+-- statically compiled code.
 main :: IO ()
 main = do
-    (cleanup, snap) <- $(loadSnapTH 'getConfig 'cleanupConfig 'site)
-
+    -- override the some of the defaults from Snap.Http.Server.Config
     let defaultFlags = mempty { flagVerbose = True
                               , flagAccessLog = Just "log/access.log"
                               , flagErrorLog = Just "log/error.log"
                               }
 
+    -- read command line args, and merge them with the defaults above
     cmdLineFlags <- readFlagsFromCmdLineArgs
     let conf = flagsToConfig $ defaultFlags `mappend` cmdLineFlags
 
+    -- This is just about the same as calling a function:
+    --
+    -- loadSnap :: IO a
+    --          -> (a -> IO ())
+    --          -> (a -> Snap ())
+    --          -> IO (IO (), Snap ())
+    --
+    -- The important parts are that it gives you back a cleanup action
+    -- and a Snap handler.  The specific behavior of each depends on
+    -- whether the Hint loader or the Static loader is imported.  This
+    -- interface abstracts across the differences between them.
+    (cleanup, snap) <- $(loadSnapTH 'getConfig 'cleanupConfig 'site)
+
+    -- Run the server
     httpServeConfig conf snap
+
+    -- Run the cleanup action before exiting
     cleanup
-----------------------------------------------------------------------


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

Reply via email to