Permalink
Browse files

Made the imports from 3rd party libraries explicit.

  • Loading branch information...
1 parent e04ec0c commit b2aebd884086eedfcd2020e6391d07b39e42abe2 @Palmik committed Jan 31, 2012
Showing with 27 additions and 24 deletions.
  1. +3 −4 src/Snap/Snaplet/MongoDB/Core.hs
  2. +12 −10 src/Snap/Snaplet/MongoDB/Functions/M.hs
  3. +12 −10 src/Snap/Snaplet/MongoDB/Functions/S.hs
@@ -12,10 +12,10 @@ module Snap.Snaplet.MongoDB.Core
import Data.Text (Text)
-import Snap
+import Snap (SnapletInit, liftIO, makeSnaplet)
-import Database.MongoDB
-import System.IO.Pool
+import Database.MongoDB (Database, Host, Pipe, AccessMode (UnconfirmedWrites), close, isClosed, connect)
+import System.IO.Pool (Pool, Factory (Factory), newPool)
------------------------------------------------------------------------------
@@ -48,7 +48,6 @@ data MongoDB = MongoDB
--
-- Usage:
--
---
-- > instance HasMongoDB App where
-- > getMongoDB = getL (snapletValue . database)
--
@@ -14,13 +14,15 @@ module Snap.Snaplet.MongoDB.Functions.M
, unsafeWithDB'
) where
-import Control.Monad.Error
+import Control.Monad.Error (runErrorT)
-import Snap
+import Snap (MonadIO, MonadState, gets, liftIO) -- transformers, mtl
+import Snap (Lens, getL) -- data-lens
+import Snap (Snaplet, snapletValue)
import Snap.Snaplet.MongoDB.Core
-import Database.MongoDB
-import System.IO.Pool
+import Database.MongoDB (Action, AccessMode, Failure (ConnectionFailure), access)
+import System.IO.Pool (aResource)
import qualified Control.Category as C ((.))
@@ -29,7 +31,7 @@ import qualified Control.Category as C ((.))
--
-- Example:
--
--- > unsafeWithDB accountDB $ insert "test-collection" ["some_field" = "something" ]
+-- > unsafeWithDB accountDB $ insert "test-collection" [ "some_field" = "something" ]
unsafeWithDB :: (MonadIO m, MonadState app m)
=> Lens app (Snaplet MongoDB) -- ^ The snaplet (database) on which you want the action to be run.
-> Action IO a -- ^ 'Action' you want to perform.
@@ -41,7 +43,7 @@ unsafeWithDB snaplet action = getMongoAccessMode snaplet >>= flip (unsafeWithDB'
--
-- Example:
--
--- > unsafeWithDB' accountDB UnconfirmedWrites $ insert "test-collection" ["some_field" = "something" ]
+-- > unsafeWithDB' accountDB UnconfirmedWrites $ insert "test-collection" [ "some_field" = "something" ]
unsafeWithDB' :: (MonadIO m, MonadState app m)
=> Lens app (Snaplet MongoDB) -- ^ The snaplet (database) on which you want the action to be run.
-> AccessMode -- ^ Access mode you want to use when performing the action.
@@ -56,7 +58,7 @@ unsafeWithDB' snaplet mode action = do
--
-- Example:
--
--- > maybeWithDB accountDB $ insert "test-collection" ["some_field" = "something" ]
+-- > maybeWithDB accountDB $ insert "test-collection" [ "some_field" = "something" ]
maybeWithDB :: (MonadIO m, MonadState app m)
=> Lens app (Snaplet MongoDB) -- ^ The snaplet (database) on which you want the action to be run.
-> Action IO a -- ^ 'Action' you want to perform.
@@ -68,7 +70,7 @@ maybeWithDB snaplet action = getMongoAccessMode snaplet >>= flip (maybeWithDB' s
--
-- Example:
--
--- > maybeWithDB' accountDB UnconfirmedWrites $ insert "test-collection" ["some_field" = "something" ]
+-- > maybeWithDB' accountDB UnconfirmedWrites $ insert "test-collection" [ "some_field" = "something" ]
maybeWithDB' :: (MonadIO m, MonadState app m)
=> Lens app (Snaplet MongoDB) -- ^ The snaplet (database) on which you want the action to be run.
-> AccessMode -- ^ Access mode you want to use when performing the action.
@@ -83,7 +85,7 @@ maybeWithDB' snaplet mode action = do
--
-- Example:
--
--- > eitherWithDB accountDB $ insert "test-collection" ["some_field" = "something" ]
+-- > eitherWithDB accountDB $ insert "test-collection" [ "some_field" = "something" ]
eitherWithDB :: (MonadIO m, MonadState app m)
=> Lens app (Snaplet MongoDB) -- ^ The snaplet (database) on which you want the action to be run.
-> Action IO a -- ^ 'Action' you want to perform.
@@ -95,7 +97,7 @@ eitherWithDB snaplet action = getMongoAccessMode snaplet >>= flip (eitherWithDB'
--
-- Example:
--
--- > eitherWithDB' accountDB UnconfirmedWrites $ insert "test-collection" ["some_field" = "something" ]
+-- > eitherWithDB' accountDB UnconfirmedWrites $ insert "test-collection" [ "some_field" = "something" ]
eitherWithDB' :: (MonadIO m, MonadState app m)
=> Lens app (Snaplet MongoDB) -- ^ The snaplet (database) on which you want the action to be run.
-> AccessMode -- ^ Access mode you want to use when performing the action.
@@ -14,20 +14,22 @@ module Snap.Snaplet.MongoDB.Functions.S
, unsafeWithDB'
) where
-import Control.Monad.Error
+import Control.Monad.Error (runErrorT)
-import Snap
+import Snap (MonadIO, MonadState, gets, liftIO) -- transformers, mtl
+import Snap (Lens, getL) -- data-lens
+import Snap (Snaplet, snapletValue)
import Snap.Snaplet.MongoDB.Core
-import Database.MongoDB
-import System.IO.Pool
+import Database.MongoDB (Action, AccessMode, Failure (ConnectionFailure), access)
+import System.IO.Pool (aResource)
------------------------------------------------------------------------------
-- | Database access function.
--
-- Usage:
--
--- > unsafeWithDB $ insert "test-collection" ["some_field" = "something" ]
+-- > unsafeWithDB $ insert "test-collection" [ "some_field" = "something" ]
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.
@@ -38,7 +40,7 @@ unsafeWithDB action = getMongoAccessMode >>= flip unsafeWithDB' action
--
-- Usage:
--
--- > unsafeWithDB' UnconfirmedWrites $ insert "test-collection" ["some_field" = "something" ]
+-- > unsafeWithDB' UnconfirmedWrites $ insert "test-collection" [ "some_field" = "something" ]
unsafeWithDB' :: (MonadIO m, MonadState app m, HasMongoDB app)
=> AccessMode -- ^ Access mode you want to use when performing the action.
-> Action IO a -- ^ 'Action' you want to perform.
@@ -52,7 +54,7 @@ unsafeWithDB' mode action = do
--
-- Usage:
--
--- > maybeWithDB $ insert "test-collection" ["some_field" = "something" ]
+-- > maybeWithDB $ insert "test-collection" [ "some_field" = "something" ]
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.
@@ -63,7 +65,7 @@ maybeWithDB action = getMongoAccessMode >>= flip maybeWithDB' action
--
-- Usage:
--
--- > maybeWithDB' UnconfirmedWrites $ insert "test-collection" ["some_field" = "something" ]
+-- > maybeWithDB' UnconfirmedWrites $ insert "test-collection" [ "some_field" = "something" ]
maybeWithDB' :: (MonadIO m, MonadState app m, HasMongoDB app)
=> AccessMode -- ^ Access mode you want to use when performing the action.
-> Action IO a -- ^ 'Action' you want to perform.
@@ -77,7 +79,7 @@ maybeWithDB' mode action = do
--
-- Usage:
--
--- > eitherWithDB $ insert "test-collection" ["some_field" = "something" ]
+-- > eitherWithDB $ insert "test-collection" [ "some_field" = "something" ]
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.
@@ -88,7 +90,7 @@ eitherWithDB action = getMongoAccessMode >>= flip eitherWithDB' action
--
-- Usage:
--
--- > eitherWithDB' UnconfirmedWrites $ insert "test-collection" ["some_field" = "something" ]
+-- > eitherWithDB' UnconfirmedWrites $ insert "test-collection" [ "some_field" = "something" ]
eitherWithDB' :: (MonadIO m, MonadState app m, HasMongoDB app)
=> AccessMode -- ^ Access mode you want to use when performing the action.
-> Action IO a -- ^ 'Action' you want to perform.

0 comments on commit b2aebd8

Please sign in to comment.