diff --git a/Database/MongoDB/Connection.hs b/Database/MongoDB/Connection.hs index 9408a5f..c53f157 100644 --- a/Database/MongoDB/Connection.hs +++ b/Database/MongoDB/Connection.hs @@ -39,7 +39,7 @@ import qualified Data.List as List import Control.Monad.Identity (runIdentity) -import Control.Monad.Error (throwError) +import Control.Monad.Except (throwError) import Control.Concurrent.MVar.Lifted (MVar, newMVar, withMVar, modifyMVar, readMVar) import Data.Bson (Document, at, (=:)) diff --git a/Database/MongoDB/GridFS.hs b/Database/MongoDB/GridFS.hs index e4f70e3..11d8c97 100644 --- a/Database/MongoDB/GridFS.hs +++ b/Database/MongoDB/GridFS.hs @@ -27,7 +27,7 @@ import Control.Applicative((<$>)) import Control.Monad(when) import Control.Monad.IO.Class -import Control.Monad.Trans(MonadTrans, lift) +import Control.Monad.Trans(lift) import Data.Conduit import Data.Digest.Pure.MD5 diff --git a/Database/MongoDB/Internal/Util.hs b/Database/MongoDB/Internal/Util.hs index 2c05138..8d84695 100644 --- a/Database/MongoDB/Internal/Util.hs +++ b/Database/MongoDB/Internal/Util.hs @@ -21,7 +21,7 @@ import System.Random.Shuffle (shuffle') import qualified Data.ByteString as S -import Control.Monad.Error (MonadError(..), Error(..)) +import Control.Monad.Except (MonadError(..)) import Control.Monad.Trans (MonadIO, liftIO) import Data.Bson import Data.Text (Text) @@ -69,9 +69,12 @@ loop :: Monad m => m (Maybe a) -> m [a] -- ^ Repeatedy execute action, collecting results, until it returns Nothing loop act = act >>= maybe (return []) (\a -> (a :) `liftM` loop act) -untilSuccess :: (MonadError e m, Error e) => (a -> m b) -> [a] -> m b +untilSuccess :: (MonadError e m) => (a -> m b) -> [a] -> m b -- ^ Apply action to elements one at a time until one succeeds. Throw last error if all fail. Throw 'strMsg' error if list is empty. -untilSuccess = untilSuccess' (strMsg "empty untilSuccess") +untilSuccess = untilSuccess' (error "empty untilSuccess") +-- Use 'error' copying behavior in removed 'Control.Monad.Error.Error' instance: +-- instance Error Failure where strMsg = error +-- 'fail' is treated the same as a programming 'error'. In other words, don't use it. untilSuccess' :: (MonadError e m) => e -> (a -> m b) -> [a] -> m b -- ^ Apply action to elements one at a time until one succeeds. Throw last error if all fail. Throw given error if list is empty diff --git a/Database/MongoDB/Query.hs b/Database/MongoDB/Query.hs index a58ec2e..d0bcc86 100644 --- a/Database/MongoDB/Query.hs +++ b/Database/MongoDB/Query.hs @@ -72,7 +72,6 @@ import Control.Concurrent.MVar.Lifted (MVar, addMVarFinalizer, import Control.Applicative ((<$>)) import Control.Exception (catch) import Control.Monad (when, void) -import Control.Monad.Error (Error(..)) import Control.Monad.Reader (MonadReader, ReaderT, runReaderT, ask, asks, local) import Control.Monad.Trans (MonadIO, liftIO) import Data.Binary.Put (runPut) @@ -138,9 +137,6 @@ instance Exception Failure type ErrorCode = Int -- ^ Error code from getLastError or query failure -instance Error Failure where strMsg = error --- ^ 'fail' is treated the same as a programming 'error'. In other words, don't use it. - -- | Type of reads and writes to perform data AccessMode = ReadStaleOk -- ^ Read-only action, reading stale data from a slave is OK.