snaplet-mongodb-minimalistic 0.0.5.1 → 0.0.6
raw patch · 5 files changed
+47/−38 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Snap.Snaplet.MongoDB.Core: type MongoDBPool = Pool IOError Pipe
Files
- snaplet-mongodb-minimalistic.cabal +22/−31
- src/Snap/Snaplet/MongoDB/Core.hs +7/−0
- src/Snap/Snaplet/MongoDB/Functions/M.hs +7/−3
- src/Snap/Snaplet/MongoDB/Functions/S.hs +8/−4
- src/Snap/Snaplet/MongoDB/Internal.hs +3/−0
snaplet-mongodb-minimalistic.cabal view
@@ -1,20 +1,24 @@-name: snaplet-mongodb-minimalistic-version: 0.0.5.1-synopsis: Minimalistic MongoDB Snaplet.-description: Minimalistic MongoDB Snaplet.-license: BSD3-license-file: LICENSE-author: Petr Pilař-maintainer: the.palmik+maintainer@gmail.com-build-type: Simple-cabal-version: >= 1.6-homepage: https://github.com/Palmik/snaplet-mongodb-minimalistic-category: Web+Name: snaplet-mongodb-minimalistic+Version: 0.0.6+Synopsis: Minimalistic MongoDB Snaplet.+Description: Minimalistic MongoDB Snaplet.+License: BSD3+License-file: LICENSE+Author: Petr Pilař+Maintainer: the.palmik+maintainer@gmail.com+Build-type: Simple+Cabal-version: >= 1.6+Homepage: https://github.com/Palmik/snaplet-mongodb-minimalistic+Category: Web -Flag development- Description: Whether to build the server in development (interpreted) mode- Default: False+Build-type: Simple +Cabal-version: >= 1.6++Source-repository head+ type: git+ location: git://github.com/Palmik/snaplet-mongodb-minimalistic.git+ Library hs-source-dirs: src @@ -25,6 +29,9 @@ Snap.Snaplet.MongoDB.Functions.S, Snap.Snaplet.MongoDB.Functions.M + Other-modules:+ Snap.Snaplet.MongoDB.Internal+ Build-depends: base >= 4 && < 5, mtl >= 2 && < 3,@@ -32,21 +39,5 @@ snap-core == 0.7.*, text >= 0.11 && < 0.12, mongoDB >= 1.1.1 && < 1.2.0-- if flag(development)- cpp-options: -DDEVELOPMENT- -- In development mode, speed is already going to suffer, so skip- -- the fancy optimization flags. Additionally, disable all- -- warnings. The hint library doesn't give an option to execute- -- compiled code when there were also warnings, so disabling- -- warnings allows quicker workflow.- ghc-options: -w- else- if impl(ghc >= 6.12.0)- ghc-options: -Wall -fwarn-tabs -funbox-strict-fields- -fno-warn-orphans -fno-warn-unused-do-bind- else- ghc-options: -Wall -fwarn-tabs -funbox-strict-fields- -fno-warn-orphans
src/Snap/Snaplet/MongoDB/Core.hs view
@@ -6,6 +6,7 @@ module Snap.Snaplet.MongoDB.Core ( MongoDB(..) , HasMongoDB(..)+, MongoDBPool , mongoDBInit ) where @@ -17,9 +18,15 @@ import System.IO.Pool ------------------------------------------------------------------------------++------------------------------------------------------------------------------ -- | Description text used in mongoDBInit as makeSnaplet argument. description :: Text description = "Minimalistic MongoDB Snaplet."++------------------------------------------------------------------------------+-- | MongoDB Pool type+type MongoDBPool = Pool IOError Pipe ------------------------------------------------------------------------------ -- | Snaplet's data type.
src/Snap/Snaplet/MongoDB/Functions/M.hs view
@@ -34,7 +34,7 @@ => Lens app (Snaplet MongoDB) -- ^ The snaplet (database) on which you want the action to be run. -> Action IO a -- ^ 'Action' you want to perform. -> m a -- ^ The action's result; in case of failure 'error' is called.-unsafeWithDB snaplet = unsafeWithDB' snaplet UnconfirmedWrites+unsafeWithDB snaplet action = getMongoAccessMode snaplet >>= flip (unsafeWithDB' snaplet) action ------------------------------------------------------------------------------ -- | Database access function.@@ -61,7 +61,7 @@ => Lens app (Snaplet MongoDB) -- ^ The snaplet (database) on which you want the action to be run. -> 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 = maybeWithDB' snaplet UnconfirmedWrites+maybeWithDB snaplet action = getMongoAccessMode snaplet >>= flip (maybeWithDB' snaplet) action ------------------------------------------------------------------------------ -- | Database access function.@@ -88,7 +88,7 @@ => Lens app (Snaplet MongoDB) -- ^ The snaplet (database) on which you want the action to be run. -> Action IO a -- ^ 'Action' you want to perform. -> m (Either Failure a) -- ^ 'Either' 'Failure' or the action's result.-eitherWithDB snaplet = eitherWithDB' snaplet UnconfirmedWrites+eitherWithDB snaplet action = getMongoAccessMode snaplet >>= flip (eitherWithDB' snaplet) action ------------------------------------------------------------------------------ -- | Database access function.@@ -107,5 +107,9 @@ case ep of Left err -> return $ Left $ ConnectionFailure err Right pip -> liftIO $ access pip mode database action++getMongoAccessMode :: (MonadIO m, MonadState app m) => Lens app (Snaplet MongoDB) -> m AccessMode+getMongoAccessMode snaplet = gets (getL ((C..) snapletValue snaplet)) >>= return . mongoAccessMode+{-# INLINE getMongoAccessMode #-}
src/Snap/Snaplet/MongoDB/Functions/S.hs view
@@ -31,7 +31,7 @@ unsafeWithDB :: (MonadIO m, MonadState app m, HasMongoDB app) => Action IO a -- ^ 'Action' you want to perform. -> m a -- ^ The action's result; in case of failure 'error' is called.-unsafeWithDB = unsafeWithDB' UnconfirmedWrites+unsafeWithDB action = getMongoAccessMode >>= flip unsafeWithDB' action ------------------------------------------------------------------------------ -- | Database access function.@@ -56,7 +56,7 @@ maybeWithDB :: (MonadIO m, MonadState app m, HasMongoDB app) => Action IO a -- ^ 'Action' you want to perform. -> m (Maybe a) -- ^ 'Nothing' in case of failure or 'Just' the result of the action.-maybeWithDB = maybeWithDB' UnconfirmedWrites+maybeWithDB action = getMongoAccessMode >>= flip maybeWithDB' action ------------------------------------------------------------------------------ -- | Database access function.@@ -81,7 +81,7 @@ eitherWithDB :: (MonadIO m, MonadState app m, HasMongoDB app) => Action IO a -- ^ 'Action' you want to perform. -> m (Either Failure a) -- ^ 'Either' 'Failure' or the action's result.-eitherWithDB = eitherWithDB' UnconfirmedWrites+eitherWithDB action = getMongoAccessMode >>= flip eitherWithDB' action ------------------------------------------------------------------------------ -- | Database access function.@@ -98,4 +98,8 @@ ep <- liftIO $ runErrorT $ aResource pool case ep of Left err -> return $ Left $ ConnectionFailure err- Right pip -> liftIO $ access pip mode database action + Right pip -> liftIO $ access pip mode database action++getMongoAccessMode :: (MonadIO m, MonadState app m, HasMongoDB app) => m AccessMode+getMongoAccessMode = gets getMongoDB >>= return . mongoAccessMode+{-# INLINE getMongoAccessMode #-}
+ src/Snap/Snaplet/MongoDB/Internal.hs view
@@ -0,0 +1,3 @@+module Snap.Snaplet.MongoDB.Internal+(+) where