Skip to content

Commit c03e1ed

Browse files
Use Control.Monad.Except instead of Control.Monad.Error.
Due to the following warning: "Module ‘Control.Monad.Error’ is deprecated: Use "Control.Monad.Except" instead"
1 parent 13f56bb commit c03e1ed

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

Database/MongoDB/Connection.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import qualified Data.List as List
3939

4040

4141
import Control.Monad.Identity (runIdentity)
42-
import Control.Monad.Error (throwError)
42+
import Control.Monad.Except (throwError)
4343
import Control.Concurrent.MVar.Lifted (MVar, newMVar, withMVar, modifyMVar,
4444
readMVar)
4545
import Data.Bson (Document, at, (=:))

Database/MongoDB/GridFS.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import Control.Applicative((<$>))
2727

2828
import Control.Monad(when)
2929
import Control.Monad.IO.Class
30-
import Control.Monad.Trans(MonadTrans, lift)
30+
import Control.Monad.Trans(lift)
3131

3232
import Data.Conduit
3333
import Data.Digest.Pure.MD5

Database/MongoDB/Internal/Util.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import System.Random.Shuffle (shuffle')
2121

2222
import qualified Data.ByteString as S
2323

24-
import Control.Monad.Error (MonadError(..), Error(..))
24+
import Control.Monad.Except (MonadError(..))
2525
import Control.Monad.Trans (MonadIO, liftIO)
2626
import Data.Bson
2727
import Data.Text (Text)
@@ -69,9 +69,12 @@ loop :: Monad m => m (Maybe a) -> m [a]
6969
-- ^ Repeatedy execute action, collecting results, until it returns Nothing
7070
loop act = act >>= maybe (return []) (\a -> (a :) `liftM` loop act)
7171

72-
untilSuccess :: (MonadError e m, Error e) => (a -> m b) -> [a] -> m b
72+
untilSuccess :: (MonadError e m) => (a -> m b) -> [a] -> m b
7373
-- ^ Apply action to elements one at a time until one succeeds. Throw last error if all fail. Throw 'strMsg' error if list is empty.
74-
untilSuccess = untilSuccess' (strMsg "empty untilSuccess")
74+
untilSuccess = untilSuccess' (error "empty untilSuccess")
75+
-- Use 'error' copying behavior in removed 'Control.Monad.Error.Error' instance:
76+
-- instance Error Failure where strMsg = error
77+
-- 'fail' is treated the same as a programming 'error'. In other words, don't use it.
7578

7679
untilSuccess' :: (MonadError e m) => e -> (a -> m b) -> [a] -> m b
7780
-- ^ Apply action to elements one at a time until one succeeds. Throw last error if all fail. Throw given error if list is empty

Database/MongoDB/Query.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ import Control.Concurrent.MVar.Lifted (MVar, addMVarFinalizer,
7272
import Control.Applicative ((<$>))
7373
import Control.Exception (catch)
7474
import Control.Monad (when, void)
75-
import Control.Monad.Error (Error(..))
7675
import Control.Monad.Reader (MonadReader, ReaderT, runReaderT, ask, asks, local)
7776
import Control.Monad.Trans (MonadIO, liftIO)
7877
import Data.Binary.Put (runPut)
@@ -138,9 +137,6 @@ instance Exception Failure
138137
type ErrorCode = Int
139138
-- ^ Error code from getLastError or query failure
140139

141-
instance Error Failure where strMsg = error
142-
-- ^ 'fail' is treated the same as a programming 'error'. In other words, don't use it.
143-
144140
-- | Type of reads and writes to perform
145141
data AccessMode =
146142
ReadStaleOk -- ^ Read-only action, reading stale data from a slave is OK.

0 commit comments

Comments
 (0)