packages feed

flock 0.2.5.2 → 0.3

raw patch · 3 files changed

+18/−11 lines, 3 filesdep +lifted-basedep +monad-controldep +transformersdep −mtlPVP ok

version bump matches the API change (PVP)

Dependencies added: lifted-base, monad-control, transformers

Dependencies removed: mtl

API changes (from Hackage documentation)

- System.Lock.FLock: withLock :: MonadIO m => FilePath -> SharedExclusive -> Block -> m a -> m a
+ System.Lock.FLock: withLock :: (MonadIO m, MonadBaseControl IO m) => FilePath -> SharedExclusive -> Block -> m a -> m a

Files

CHANGELOG view
@@ -1,3 +1,7 @@+0.3+  * Protect against exception in withLock using monad-control. Thanks+    to Takahiro Himura for this feature.+ 0.2.5.2   * Build with current Cabal. Thanks to Mitsutoshi Aoe for this fix. 
System/Lock/FLock.hsc view
@@ -1,9 +1,9 @@-{-# LANGUAGE ForeignFunctionInterface, CPP #-}+{-# LANGUAGE ForeignFunctionInterface, CPP, FlexibleContexts #-} module System.Lock.FLock       (withLock, lock, unlock,        SharedExclusive(Shared, Exclusive), Block(Block, NoBlock), Lock) where -import Control.Monad.Trans (MonadIO, liftIO)+import Control.Monad.IO.Class (MonadIO (..)) import Data.Bits ((.|.)) #if __GLASGOW_HASKELL__ > 702 import Foreign.C.Types (CInt(..))@@ -14,6 +14,8 @@ import System.Posix.IO (openFd, defaultFileFlags, closeFd,                         OpenMode(ReadOnly, WriteOnly)) import System.Posix.Types (Fd(Fd))+import Control.Monad.Trans.Control (MonadBaseControl)+import Control.Exception.Lifted (bracket)  #include <sys/file.h> @@ -31,13 +33,12 @@  newtype Lock = Lock CInt --- We should really use something like bracket, but being in MonadIO makes--- that tricky-withLock :: MonadIO m => FilePath -> SharedExclusive -> Block -> m a -> m a-withLock fp se b x = do l <- lock fp se b-                        r <- x-                        unlock l-                        return r+withLock :: (MonadIO m, MonadBaseControl IO m) => FilePath -> SharedExclusive -> Block -> m a -> m a+withLock fp se b x =+  bracket+    (lock fp se b)+    unlock+    (const x)  lock :: MonadIO m => FilePath -> SharedExclusive -> Block -> m Lock lock fp se b = liftIO
flock.cabal view
@@ -1,5 +1,5 @@ Name:               flock-Version:            0.2.5.2+Version:            0.3 License:            OtherLicense License-File:       COPYING Copyright:          Ian Lynagh, 2007@@ -22,7 +22,9 @@  Library   Build-Depends:      base > 3 && < 5-                    , mtl == 1.1.* || == 2.0.*+                    , transformers >= 0.2 && < 0.3+                    , monad-control >= 0.3 && < 0.4+                    , lifted-base >= 0.1 && < 0.2                     , unix >= 2.3 && < 2.6   Exposed-modules:    System.Lock.FLock   GHC-Options:        -Wall