Skip to content
Browse files

Cosmetic changes.

  • Loading branch information...
1 parent 0627e27 commit 1ce1b8a58cb9b4cbd860f0984787d22fa7bbee8f @Palmik committed Jan 2, 2013
View
BIN dist/snaplet-mongodb-minimalistic-0.0.1.tar.gz
Binary file not shown.
View
BIN dist/snaplet-mongodb-minimalistic-0.0.2.tar.gz
Binary file not shown.
View
BIN dist/snaplet-mongodb-minimalistic-0.0.3.tar.gz
Binary file not shown.
View
BIN dist/snaplet-mongodb-minimalistic-0.0.4.tar.gz
Binary file not shown.
View
BIN dist/snaplet-mongodb-minimalistic-0.0.5.1.tar.gz
Binary file not shown.
View
BIN dist/snaplet-mongodb-minimalistic-0.0.6.1.tar.gz
Binary file not shown.
View
BIN dist/snaplet-mongodb-minimalistic-0.0.6.2.tar.gz
Binary file not shown.
View
BIN dist/snaplet-mongodb-minimalistic-0.0.6.3.tar.gz
Binary file not shown.
View
BIN dist/snaplet-mongodb-minimalistic-0.0.6.5.tar.gz
Binary file not shown.
View
BIN dist/snaplet-mongodb-minimalistic-0.0.6.tar.gz
Binary file not shown.
View
2 snaplet-mongodb-minimalistic.cabal
@@ -1,5 +1,5 @@
Name: snaplet-mongodb-minimalistic
-Version: 0.0.6.5
+Version: 0.0.6.6
Synopsis: Minimalistic MongoDB Snaplet.
Description: Minimalistic MongoDB Snaplet.
License: BSD3
View
12 src/Snap/Snaplet/MongoDB/Functions/M.hs
@@ -14,6 +14,7 @@ module Snap.Snaplet.MongoDB.Functions.M
, unsafeWithDB'
) where
+import Control.Monad (liftM)
import Control.Monad.Error (runErrorT)
import Control.Lens (cloneLens, use)
@@ -49,7 +50,7 @@ unsafeWithDB' :: (MonadIO m, MonadState app m)
-> Action IO a -- ^ 'Action' you want to perform.
-> m a -- ^ The action's result; in case of failure 'error' is called.
unsafeWithDB' snaplet mode action = do
- res <- (eitherWithDB' snaplet mode action)
+ res <- eitherWithDB' snaplet mode action
either (error . show) return res
------------------------------------------------------------------------------
@@ -76,7 +77,7 @@ maybeWithDB' :: (MonadIO m, MonadState app m)
-> Action IO a -- ^ 'Action' you want to perform.
-> m (Maybe a) -- ^ 'Nothing' in case of failure or 'Just' the result of the action.
maybeWithDB' snaplet mode action = do
- res <- (eitherWithDB' snaplet mode action)
+ res <- eitherWithDB' snaplet mode action
return $ either (const Nothing) Just res
------------------------------------------------------------------------------
@@ -103,15 +104,12 @@ eitherWithDB' :: (MonadIO m, MonadState app m)
-> Action IO a -- ^ 'Action' you want to perform.
-> m (Either Failure a) -- ^ 'Either' 'Failure' or the action's result.
eitherWithDB' snaplet mode action = do
- (MongoDB pool database _) <- use (snaplet'.snapletValue)
+ (MongoDB pool database _) <- use (cloneLens snaplet . snapletValue)
ep <- liftIO $ runErrorT $ aResource pool
case ep of
Left err -> return $ Left $ ConnectionFailure err
Right pip -> liftIO $ access pip mode database action
- where
- snaplet' = cloneLens snaplet
getMongoAccessMode :: (MonadIO m, MonadState app m) => SnapletLens app MongoDB -> m AccessMode
-getMongoAccessMode snaplet = use (snaplet'.snapletValue) >>= return . mongoAccessMode
- where snaplet' = cloneLens snaplet
+getMongoAccessMode snaplet = mongoAccessMode `liftM` use (cloneLens snaplet . snapletValue)
{-# INLINE getMongoAccessMode #-}

0 comments on commit 1ce1b8a

Please sign in to comment.
Something went wrong with that request. Please try again.