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 5d47444bcc5b9d4565a58fcc1f0e0d3b1d085674 (commit)
from 1bd7d9d8dacc837ee5c25fd0145f8f2d0e930969 (commit)
Summary of changes:
src/Snap/Extension.hs | 67 ++++++++++++++++++++------------------
src/Snap/Extension/Heist.hs | 14 ++++----
src/Snap/Extension/Heist/Impl.hs | 23 +++++++------
src/Snap/StarterTH.hs | 3 +-
4 files changed, 56 insertions(+), 51 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 5d47444bcc5b9d4565a58fcc1f0e0d3b1d085674
Author: Mighty Byte <[email protected]>
Date: Sat Feb 5 14:24:49 2011 -0500
Style cleanup
diff --git a/src/Snap/Extension.hs b/src/Snap/Extension.hs
index 749af01..842d84b 100644
--- a/src/Snap/Extension.hs
+++ b/src/Snap/Extension.hs
@@ -82,9 +82,9 @@ import System.IO
implementations live in Snap.Extension.Session.HDBC,
Snap.Extension.Session.MongoDB and Snap.Extension.Session.CookieStore.
- Keeping this in mind, there are a number of things you need to do to use Snap
- extensions in your application. Let's walk through how to set up a simple
- application with the Heist extension turned on.
+ Keeping this in mind, there are a number of things you need to do to use
+ Snap extensions in your application. Let's walk through how to set up a
+ simple application with the Heist extension turned on.
-}
@@ -112,11 +112,11 @@ data AppState = AppState
{ heistState :: HeistState App }
@
- An important thing to note is that the -State types that we use in the fields
- of AppState are specific to each implementation of a extension's interface.
- That is, Snap.Extension.Session.HDBC will export a different SessionState to
- Snap.Extension.Session.CookieStore, whose internal representation might be
- completely different.
+ An important thing to note is that the -State types that we use in the
+ fields of AppState are specific to each implementation of a extension's
+ interface. That is, Snap.Extension.Session.HDBC will export a different
+ SessionState to Snap.Extension.Session.CookieStore, whose internal
+ representation might be completely different.
This state is what the extension's implementation needs to be able to do its
job.
@@ -130,13 +130,13 @@ data AppState = AppState
actually get to use this interface and all the functionality that these
extensions export? What is actually being extended?
- We use the interface provided by an extension inside our application's monad,
- App. Snap extensions extend our App with new functionality by allowing us to
- user their exported functions inside of our handlers. For example, the Heist
- extension provides the function:
+ We use the interface provided by an extension inside our application's
+ monad, App. Snap extensions extend our App with new functionality by
+ allowing us to user their exported functions inside of our handlers. For
+ example, the Heist extension provides the function:
- @render :: MonadHeist m => ByteString -> m ()@ that renders a template by its
- name.
+ @render :: MonadHeist m => ByteString -> m ()@ that renders a template by
+ its name.
Is App a 'MonadHeist'? Well, not quite yet. Any 'MonadReader' which is also
a 'MonadSnap' whose environment contains a 'HeistState' is a 'MonadHeist'.
@@ -215,23 +215,24 @@ main = do
quickHttpServe site `finally` cleanup
@
- You'll notice we're using 'defaultReloadHandler'. This is a function exported
- by "Snap.Extension" with the type signature
+ You'll notice we're using 'defaultReloadHandler'. This is a function
+ exported by "Snap.Extension" with the type signature
@MonadSnap m => IO [(ByteString, Maybe ByteString)] -> m ()@ It takes the
reload action returned by 'runInitializer' and returns a 'Snap' action which
- renders a simple page showing how the reload went. To avoid denial-of-service
- attacks, the reload handler only works for requests made from the local host.
+ renders a simple page showing how the reload went. To avoid denial of
+ service attacks, the reload handler only works for requests made from the
+ local host.
-}
{- $httpserve
This is, of course, a lot of avoidable boilerplate. Snap extensions framework
- comes with another module "Snap.Extension.Server", which provides an interface
- mimicking that of "Snap.Http.Server". Their function names clash, so if you
- need to use both of them in the same module, use a qualified import. Using
- this module, the example above becomes:
+ comes with another module "Snap.Extension.Server", which provides an
+ interface mimicking that of "Snap.Http.Server". Their function names clash,
+ so if you need to use both of them in the same module, use a qualified
+ import. Using this module, the example above becomes:
@
import Snap.Extension.Server
@@ -248,7 +249,7 @@ main = quickHttpServe appRunner site
defaults augmented with any options specified on the command-line. The
default reload handler path in this case is "admin/reload".
- If you wanted to change this to nullReloadHandler, this is what you would do:
+ If you wanted to change this to nullReloadHandler, you would do this:
@
import Snap.Extension.Server
@@ -366,9 +367,9 @@ runInitializer
-- ^ A web handler in your application's monad
-> IO (Snap (), IO (), IO [(ByteString, Maybe ByteString)])
-- ^ Returns a 'Snap' handler, a cleanup action, and a reload action. The
- -- list returned by the reload action is for error reporting. There is one
- -- tuple in the list for each Snap extension; the first element of the
- -- tuple is the name of the Snap extension, and the second is a Maybe
+ -- list returned by the reload action is for error reporting. There is
+ -- one tuple in the list for each Snap extension; the first element of
+ -- the tuple is the name of the Snap extension, and the second is a Maybe
-- which contains Nothing if there was no error reloading that extension
-- and a Just with the ByteString containing the error message if there
-- was.
@@ -422,9 +423,10 @@ runInitializerWithoutReloadAction i se = do
------------------------------------------------------------------------------
instance Functor Initializer where
- fmap f (Initializer r) = Initializer $ \v -> r v >>= \e -> return $ case e
of
- Left s -> Left $ f s
- Right (SCR s a b) -> Right $ SCR (f s) a b
+ fmap f (Initializer r) = Initializer $ \v -> r v >>= \e -> return $
+ case e of
+ Left s -> Left $ f s
+ Right (SCR s a b) -> Right $ SCR (f s) a b
------------------------------------------------------------------------------
@@ -450,9 +452,10 @@ instance MonadIO Initializer where
join' :: Initializer (Initializer s) -> Initializer s
join' (Initializer r) = Initializer $ \v -> r v >>= \e -> case e of
Left (Initializer r') -> r' v
- Right (SCR (Initializer r') a b) -> r' v >>= \e' -> return $ Right $ case
e' of
- Left s -> SCR s a b
- Right (SCR s a' b') -> SCR s (a' >> a) (liftM2 (++) b b')
+ Right (SCR (Initializer r') a b) -> r' v >>= \e' -> return $ Right $
+ case e' of
+ Left s -> SCR s a b
+ Right (SCR s a' b') -> SCR s (a' >> a) (liftM2 (++) b b')
------------------------------------------------------------------------------
diff --git a/src/Snap/Extension/Heist.hs b/src/Snap/Extension/Heist.hs
index 470c3c9..41ceed9 100644
--- a/src/Snap/Extension/Heist.hs
+++ b/src/Snap/Extension/Heist.hs
@@ -14,16 +14,16 @@ and 'render' into a single function call.
and can be used to turn your application's monad into a 'MonadHeist'.
'MonadHeist' is unusual among Snap extensions in that it's a multi-parameter
-typeclass. The last parameter is your application's monad, and the first is the
-monad you want the 'TemplateState' to use. This is usually, but not always,
-also your application's monad.
+typeclass. The last parameter is your application's monad, and the first is
+the monad you want the 'TemplateState' to use. This is usually, but not
+always, also your application's monad.
This module should not be used directly. Instead, import
"Snap.Extension.Heist.Impl" in your application.
-}
-module Snap.Extension.Heist
+module Snap.Extension.Heist
( MonadHeist(..)
, renderWithSplices ) where
@@ -68,10 +68,10 @@ class (Monad n, MonadSnap m) => MonadHeist n m | m -> n
where
------------------------------------------------------------------------------
--- | Helper function for common use case:
+-- | Helper function for common use case:
-- Render a template with a given set of splices.
-renderWithSplices
- :: (MonadHeist n m)
+renderWithSplices
+ :: (MonadHeist n m)
=> ByteString -- ^ Template to render
-> [(Text, Splice n)] -- ^ Splice mapping
-> m ()
diff --git a/src/Snap/Extension/Heist/Impl.hs b/src/Snap/Extension/Heist/Impl.hs
index 47e9932..22ab245 100644
--- a/src/Snap/Extension/Heist/Impl.hs
+++ b/src/Snap/Extension/Heist/Impl.hs
@@ -47,8 +47,8 @@ interfaces from any other Snap Extension.
-}
module Snap.Extension.Heist.Impl
- (
-
+ (
+
-- * Heist State Definitions
HeistState
, HasHeistState(..)
@@ -75,7 +75,7 @@ import Text.Templating.Heist.Splices.Static
------------------------------------------------------------------------------
-- | Your application's state must include a 'HeistState' in order for your
--- application to be a 'MonadHeist'.
+-- application to be a 'MonadHeist'.
--
-- Unlike other @-State@ types, this is of kind @(* -> *) -> *@. Unless you're
-- developing your own Snap Extension which has its own internal 'HeistState',
@@ -142,7 +142,8 @@ instance MonadSnap m => InitializerState (HeistState m)
where
------------------------------------------------------------------------------
-instance HasHeistState (SnapExtend s) s => MonadHeist (SnapExtend s)
(SnapExtend s) where
+instance HasHeistState (SnapExtend s) s
+ => MonadHeist (SnapExtend s) (SnapExtend s) where
render t = do
hs <- asks getHeistState
renderHelper hs Nothing t
@@ -185,7 +186,7 @@ renderHelper hs c t = do
-- inside your application's 'Initializer'.
--
-- Typical use cases are dynamically generated components that are present in
--- many of your views.
+-- many of your views.
--
-- Example Usage:
--
@@ -193,17 +194,17 @@ renderHelper hs c t = do
-- appInit :: Initializer AppState
-- appInit = do
-- hs <- heistInitializer \"templates\"
--- registerSplices hs $
+-- registerSplices hs $
-- [ (\"tabs\", tabsSplice)
--- , (\"loginLogout\", loginLogoutSplice) ]
+-- , (\"loginLogout\", loginLogoutSplice) ]
-- @
registerSplices
- :: (MonadSnap m, MonadIO n)
- => HeistState m
+ :: (MonadSnap m, MonadIO n)
+ => HeistState m
-- ^ Heist state that you are going to embed in your application's state.
- -> [(Text, Splice m)]
+ -> [(Text, Splice m)]
-- ^ Your splices.
-> n ()
registerSplices s sps = liftIO $ do
let mv = _tsMVar s
- modifyMVar_ mv $ (return . bindSplices sps)
+ modifyMVar_ mv $ (return . bindSplices sps)
diff --git a/src/Snap/StarterTH.hs b/src/Snap/StarterTH.hs
index 96d55cb..581a31c 100644
--- a/src/Snap/StarterTH.hs
+++ b/src/Snap/StarterTH.hs
@@ -19,7 +19,8 @@ type DirData = FilePath
------------------------------------------------------------------------------
-- Gets all the directorys in a DirTree
getDirs :: [FilePath] -> DirTree a -> [FilePath]
-getDirs prefix (Dir n c) = (intercalate "/" (reverse (n:prefix))) : concatMap
(getDirs (n:prefix)) c
+getDirs prefix (Dir n c) = (intercalate "/" (reverse (n:prefix))) :
+ concatMap (getDirs (n:prefix)) c
getDirs _ (File _ _) = []
getDirs _ (Failed _ _) = []
-----------------------------------------------------------------------
hooks/post-receive
--
snap
_______________________________________________
Snap mailing list
[email protected]
http://mailman-mail5.webfaction.com/listinfo/snap