packages feed

lifted-base 0.1 → 0.1.0.1

raw patch · 6 files changed

+66/−16 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

Control/Concurrent/Lifted.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE UnicodeSyntax, NoImplicitPrelude, FlexibleContexts, RankNTypes #-}+{-# LANGUAGE CPP, UnicodeSyntax, NoImplicitPrelude, FlexibleContexts, RankNTypes #-}  {- | Module      :  Control.Concurrent.Lifted@@ -19,15 +19,19 @@       -- * Basic concurrency operations     , myThreadId     , fork+#if MIN_VERSION_base(4,4,0)     , forkWithUnmask+#endif     , killThread     , throwTo +#if MIN_VERSION_base(4,4,0)       -- ** Threads with affinity     , forkOn     , forkOnWithUnmask     , getNumCapabilities     , threadCapability+#endif        -- * Scheduling     , yield@@ -65,7 +69,6 @@ import Data.Bool          ( Bool ) import Data.Int           ( Int ) import Data.Function      ( ($) )-import Control.Monad      ( void ) import System.IO          ( IO ) import System.Posix.Types ( Fd ) import Control.Exception  ( Exception )@@ -80,13 +83,19 @@ import Control.Monad.Base ( MonadBase, liftBase )  -- from monad-control:-import Control.Monad.Trans.Control-    ( MonadBaseControl, liftBaseWith, liftBaseOp_, liftBaseDiscard )+import Control.Monad.Trans.Control ( MonadBaseControl, liftBaseOp_, liftBaseDiscard ) +#if MIN_VERSION_base(4,4,0)+import Control.Monad.Trans.Control ( liftBaseWith )+import Control.Monad               ( void )+#endif+ -- from lifted-base (this package): import Control.Concurrent.MVar.Lifted +#include "inlinable.h" + -------------------------------------------------------------------------------- -- Control.Concurrent --------------------------------------------------------------------------------@@ -105,6 +114,7 @@ fork = liftBaseDiscard C.forkIO {-# INLINABLE fork #-} +#if MIN_VERSION_base(4,4,0) -- | Generalized version of 'C.forkIOWithUnmask'. -- -- Note that, while the forked computation @m ()@ has access to the captured@@ -115,6 +125,7 @@                      C.forkIOWithUnmask $ \unmask →                        void $ runInIO $ f $ liftBaseOp_ unmask {-# INLINABLE  forkWithUnmask #-}+#endif  -- | Generalized version of 'C.killThread'. killThread ∷ MonadBase IO m ⇒ ThreadId → m ()@@ -126,6 +137,7 @@ throwTo tid e = liftBase $ C.throwTo tid e {-# INLINABLE throwTo #-} +#if MIN_VERSION_base(4,4,0) -- | Generalized version of 'C.forkOn'. -- -- Note that, while the forked computation @m ()@ has access to the captured@@ -155,6 +167,7 @@ threadCapability ∷ MonadBase IO m ⇒ ThreadId → m (Int, Bool) threadCapability = liftBase ∘ C.threadCapability {-# INLINABLE threadCapability #-}+#endif  -- | Generalized version of 'C.yield'. yield ∷ MonadBase IO m ⇒ m ()
Control/Concurrent/MVar/Lifted.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE UnicodeSyntax, NoImplicitPrelude, FlexibleContexts #-}+{-# LANGUAGE CPP, UnicodeSyntax, NoImplicitPrelude, FlexibleContexts #-}  {- | Module      :  Control.Concurrent.MVar.Lifted@@ -43,6 +43,10 @@ import           Control.Concurrent.MVar  ( MVar ) import qualified Control.Concurrent.MVar as MVar +#if __GLASGOW_HASKELL__ < 700+import Control.Monad ( (>>=), (>>), fail )+#endif+ -- from base-unicode-symbols: import Data.Function.Unicode ( (∘) ) @@ -53,8 +57,15 @@ import Control.Monad.Trans.Control ( MonadBaseControl, liftBaseOp, liftBaseDiscard )  -- from lifted-base (this package):-import Control.Exception.Lifted ( mask, onException )+import Control.Exception.Lifted ( onException+#if MIN_VERSION_base(4,3,0)+                                , mask+#else+                                , block, unblock+#endif+                                ) +#include "inlinable.h"  -------------------------------------------------------------------------------- -- * MVars@@ -112,19 +123,34 @@  -- | Generalized version of 'MVar.modifyMVar_'. modifyMVar_ ∷ (MonadBaseControl IO m, MonadBase IO m) ⇒ MVar α → (α → m α) → m ()++-- | Generalized version of 'MVar.modifyMVar'.+modifyMVar ∷ (MonadBaseControl IO m, MonadBase IO m) ⇒ MVar α → (α → m (α, β)) → m β++#if MIN_VERSION_base(4,3,0) modifyMVar_ mv f = mask $ \restore → do                      x  ← takeMVar mv                      x' ← restore (f x) `onException` putMVar mv x                      putMVar mv x'-{-# INLINABLE modifyMVar_ #-} --- | Generalized version of 'MVar.modifyMVar'.-modifyMVar ∷ (MonadBaseControl IO m, MonadBase IO m) ⇒ MVar α → (α → m (α, β)) → m β modifyMVar mv f = mask $ \restore → do                     x       ← takeMVar mv                     (x', y) ← restore (f x) `onException` putMVar mv x                     putMVar mv x'                     return y+#else+modifyMVar_ mv f = block $ do+                     x  ← takeMVar mv+                     x' ← unblock (f x) `onException` putMVar mv x+                     putMVar mv x'++modifyMVar mv f = block $ do+                    x       ← takeMVar mv+                    (x', y) ← unblock (f x) `onException` putMVar mv x+                    putMVar mv x'+                    return y+#endif+{-# INLINABLE modifyMVar_ #-} {-# INLINABLE modifyMVar #-}  -- | Generalized version of 'MVar.addMVarFinalizer'.
Control/Exception/Lifted.hs view
@@ -74,10 +74,7 @@ import Data.Maybe      ( Maybe ) import Control.Monad   ( Monad, (>>=), return, liftM ) import System.IO.Error ( IOError )--#if MIN_VERSION_base(4,3,0) || defined (__HADDOCK__) import System.IO       ( IO )-#endif  #if __GLASGOW_HASKELL__ < 700 import Control.Monad   ( fail )@@ -123,6 +120,7 @@ import Control.Monad.Trans.Control ( liftBaseOp ) #endif +#include "inlinable.h"  -------------------------------------------------------------------------------- -- * Throwing exceptions
System/Timeout/Lifted.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE UnicodeSyntax, NoImplicitPrelude, FlexibleContexts #-}+{-# LANGUAGE CPP, UnicodeSyntax, NoImplicitPrelude, FlexibleContexts #-}  ------------------------------------------------------------------------------- -- |@@ -29,6 +29,8 @@  -- from monad-control: import Control.Monad.Trans.Control ( MonadBaseControl, restoreM, liftBaseWith )++#include "inlinable.h"  -- | Generalized version of 'T.timeout'. --
+ include/inlinable.h view
@@ -0,0 +1,3 @@+#if __GLASCOW_HASKELL__ < 700+#define INLINABLE INLINE +#endif
lifted-base.cabal view
@@ -1,5 +1,5 @@ Name:                lifted-base-Version:             0.1+Version:             0.1.0.1 Synopsis:            lifted IO operations from the base library License:             BSD3 License-file:        LICENSE@@ -26,6 +26,8 @@ -- TODO: Remove when http://hackage.haskell.org/trac/hackage/ticket/792 is fixed: extra-source-files:  test.hs +extra-source-files: include/inlinable.h+ --------------------------------------------------------------------------------  source-repository head@@ -45,6 +47,9 @@                , transformers-base    >= 0.4   && < 0.5                , monad-control        >= 0.3   && < 0.4 +  Include-dirs: include+  Includes:     inlinable.h+   Ghc-options: -Wall  --------------------------------------------------------------------------------@@ -53,8 +58,6 @@   type:    exitcode-stdio-1.0   main-is: test.hs -  ghc-options: -Wall-   build-depends: base                 >= 3     && < 4.5                , base-unicode-symbols >= 0.1.1 && < 0.3                , transformers         >= 0.2   && < 0.3@@ -63,5 +66,10 @@                , HUnit                >= 1.2.2 && < 1.3                , test-framework       >= 0.2.4 && < 0.5                , test-framework-hunit >= 0.2.4 && < 0.3++  Include-dirs: include+  Includes:     inlinable.h++  ghc-options: -Wall  --------------------------------------------------------------------------------