packages feed

simple-log 0.3.4 → 0.4.0

raw patch · 4 files changed

+23/−19 lines, 4 filesdep +exceptionsdep −MonadCatchIO-transformersdep ~time

Dependencies added: exceptions

Dependencies removed: MonadCatchIO-transformers

Dependency ranges changed: time

Files

LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2012, Alexandr `Voidex` Ruchkin
+Copyright (c) 2013, Alexandr `Voidex` Ruchkin
 
 All rights reserved.
 
simple-log.cabal view
@@ -1,5 +1,5 @@ Name:                 simple-log
-Version:              0.3.4
+Version:              0.4.0
 Synopsis:             Simple log for Haskell
 Description:          Log library for Haskell with removing unnecessary traces
 License:              BSD3
@@ -12,6 +12,10 @@ Cabal-version:        >= 1.6
 Tested-with:          GHC == 7.6.1
 
+source-repository head
+  type: git
+  location: git://github.com/mvoidex/simple-log.git
+
 Library
   HS-Source-Dirs: src
   Build-Depends:
@@ -20,12 +24,12 @@     containers >= 0.5 && < 0.6,
     deepseq >= 1.4 && < 1.5,
     directory >= 1.2 && < 1.3,
+    exceptions >= 0.8 && < 0.9,
     filepath >= 1.4 && < 1.5,
-    MonadCatchIO-transformers >= 0.2 && < 0.4,
     mtl >= 2.2 && < 2.3,
     SafeSemaphore >= 0.9.0 && < 1.0.0,
     text >= 0.11.0 && < 2.0.0,
-    time >= 1.5 && < 1.6,
+    time >= 1.5 && < 1.7,
     transformers >= 0.4 && < 0.6
   Exposed-Modules:
     System.Log.Simple
src/System/Log/Simple/Base.hs view
@@ -31,8 +31,8 @@ import Control.Concurrent.MSem
 import Control.DeepSeq
 import Control.Monad
+import Control.Monad.Catch
 import Control.Monad.IO.Class
-import Control.Monad.CatchIO
 import Data.List
 import qualified Data.Map as M
 import Data.Maybe (catMaybes, isJust)
@@ -273,7 +273,7 @@ stopLog (Log _ stop _) = liftIO stop
 
 -- | New log-scope
-scopeLog_ :: MonadCatchIO m => Log -> Text -> m a -> m a
+scopeLog_ :: (MonadIO m, MonadMask m) => Log -> Text -> m a -> m a
 scopeLog_ (Log post _ getRules) s act = do
     rs <- liftIO getRules
     sem <- liftIO $ new (0 :: Integer)
@@ -283,15 +283,15 @@         act
 
 -- | New log-scope with lifting exceptions as errors
-scopeLog :: MonadCatchIO m => Log -> Text -> m a -> m a
+scopeLog :: (MonadIO m, MonadMask m) => Log -> Text -> m a -> m a
 scopeLog l s act = scopeLog_ l s (catch act onError) where
-    onError :: MonadIO m => E.SomeException -> m a
+    onError :: (MonadIO m, MonadThrow m) => E.SomeException -> m a
     onError e = do
         writeLog l Error $ fromString $ "Scope leaves with exception: " ++ show e
-        throw e
+        throwM e
 
 -- | New log-scope with tracing scope result
-scoperLog :: MonadCatchIO m => Show a => Log -> Text -> m a -> m a
+scoperLog :: (MonadIO m, MonadMask m) => Show a => Log -> Text -> m a -> m a
 scoperLog l s act = do
     r <- scopeLog l s act
     writeLog l Trace $ T.concat ["Scope ", s, " leaves with result: ", fromString . show $ r]
src/System/Log/Simple/Monad.hs view
@@ -23,17 +23,17 @@ import Control.Monad.IO.Class
 import Control.Monad.Reader
 import Control.Monad.Except
-import Control.Monad.CatchIO as C
+import Control.Monad.Catch
 import Data.String
 import Data.Text (Text)
 import qualified Data.Text as T
 import Data.Time
 import System.Log.Simple.Base
 
-class (MonadCatchIO m) => MonadLog m where
+class (MonadIO m, MonadMask m) => MonadLog m where
     askLog :: m Log
 
-instance (MonadCatchIO m) => MonadLog (ReaderT Log m) where
+instance (MonadIO m, MonadMask m) => MonadLog (ReaderT Log m) where
     askLog = ask
 
 withNoLog :: ReaderT Log m a -> m a
@@ -57,11 +57,11 @@ 
 -- | Scope with log all exceptions
 scope :: (MonadLog m) => Text -> m a -> m a
-scope s act = scope_ s $ C.catch act onError where
+scope s act = scope_ s $ catch act onError where
     onError :: (MonadLog m) => SomeException -> m a
     onError e = do
         log Error $ T.concat ["Scope leaves with exception: ", fromString . show $ e]
-        throw e
+        throwM e
 
 -- | Workaround: we must explicitely post 'LeaveScope'
 scopeM_ :: (MonadLog m, MonadError e m) => Text -> m a -> m a
@@ -78,9 +78,9 @@ -- | Scope with log exceptions from 'MonadError'
 -- | Workaround: we must explicitely post 'LeaveScope'
 scopeM :: (Show e, MonadLog m, MonadError e m) => Text -> m a -> m a
-scopeM s act = scopeM_ s $ C.catch act' onError' where
+scopeM s act = scopeM_ s $ catch act' onError' where
     onError' :: (MonadLog m) => SomeException -> m a
-    onError' e = logE e >> throw e
+    onError' e = logE e >> throwM e
     act' = catchError act onError
     onError :: (MonadLog m, Show e, MonadError e m) => e -> m a
     onError e = logE e >> throwError e
@@ -102,14 +102,14 @@ 
 -- | Ignore error
 ignoreError :: (MonadLog m) => m () -> m ()
-ignoreError act = C.catch act onError where
+ignoreError act = catch act onError where
     onError :: (MonadLog m) => SomeException -> m ()
     onError _ = return ()
 
 -- | Ignore MonadError error
 ignoreErrorM :: (MonadLog m, MonadError e m) => m () -> m ()
 ignoreErrorM act = catchError act onError where
-    onError :: (MonadLog m, MonadError e m) => e -> m ()
+    onError :: MonadLog m => e -> m ()
     onError _ = return ()
 
 -- | Trace value