Merge pull request #304 from barrucadu/newtvarconc

Add newTVarConc to MonadConc
This commit is contained in:
Michael Walker 2019-11-16 14:59:15 +00:00 committed by GitHub
commit 1e016e09bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 6 deletions

View File

@ -45,7 +45,7 @@ There are a few different packages under the Déjà Fu umbrella:
| | Version | Summary | | | Version | Summary |
| - | ------- | ------- | | - | ------- | ------- |
| [concurrency][h:conc] | 1.8.0.0 | Typeclasses, functions, and data types for concurrency and STM. | | [concurrency][h:conc] | 1.8.1.0 | Typeclasses, functions, and data types for concurrency and STM. |
| [dejafu][h:dejafu] | 2.1.0.1 | Systematic testing for Haskell concurrency. | | [dejafu][h:dejafu] | 2.1.0.1 | Systematic testing for Haskell concurrency. |
| [hunit-dejafu][h:hunit] | 2.0.0.1 | Deja Fu support for the HUnit test framework. | | [hunit-dejafu][h:hunit] | 2.0.0.1 | Deja Fu support for the HUnit test framework. |
| [tasty-dejafu][h:tasty] | 2.0.0.1 | Deja Fu support for the Tasty test framework. | | [tasty-dejafu][h:tasty] | 2.0.0.1 | Deja Fu support for the Tasty test framework. |

View File

@ -7,6 +7,19 @@ standard Haskell versioning scheme.
.. _PVP: https://pvp.haskell.org/ .. _PVP: https://pvp.haskell.org/
1.8.1.0 (2019-11-16)
====================
* Git: :tag:`concurrency-1.8.1.0`
* Hackage: :hackage:`concurrency-1.8.1.0`
Added
~~~~~
* (:issue:`303`) ``Control.Monad.Conc.Class.newTVarConc``, with a
default implementation of ``atomically . newTVar``.
1.8.0.0 (2019-10-04) 1.8.0.0 (2019-10-04)
-------------------- --------------------

View File

@ -9,7 +9,7 @@
-- | -- |
-- Module : Control.Monad.Conc.Class -- Module : Control.Monad.Conc.Class
-- Copyright : (c) 2016--2018 Michael Walker -- Copyright : (c) 2016--2019 Michael Walker
-- License : MIT -- License : MIT
-- Maintainer : Michael Walker <mike@barrucadu.co.uk> -- Maintainer : Michael Walker <mike@barrucadu.co.uk>
-- Stability : experimental -- Stability : experimental
@ -97,7 +97,7 @@ import Control.Monad.Catch (MonadCatch, MonadMask,
import qualified Control.Monad.Catch as Ca import qualified Control.Monad.Catch as Ca
import Control.Monad.Fail (MonadFail(..)) import Control.Monad.Fail (MonadFail(..))
import Control.Monad.STM.Class (IsSTM, MonadSTM, TVar, fromIsSTM, import Control.Monad.STM.Class (IsSTM, MonadSTM, TVar, fromIsSTM,
readTVar) newTVar, readTVar)
import Control.Monad.Trans.Control (MonadTransControl, StT, liftWith) import Control.Monad.Trans.Control (MonadTransControl, StT, liftWith)
import Data.Proxy (Proxy(..)) import Data.Proxy (Proxy(..))
@ -472,6 +472,14 @@ class ( Monad m
-- @since 1.0.0.0 -- @since 1.0.0.0
atomically :: STM m a -> m a atomically :: STM m a -> m a
-- | Create a @TVar@. This may be implemented differently for speed.
--
-- > newTVarConc = atomically . newTVar
--
-- @since 1.8.1.0
newTVarConc :: a -> m (TVar (STM m) a)
newTVarConc = atomically . newTVar
-- | Read the current value stored in a @TVar@. This may be -- | Read the current value stored in a @TVar@. This may be
-- implemented differently for speed. -- implemented differently for speed.
-- --
@ -774,6 +782,7 @@ instance MonadConc IO where
casIORef = IO.casIORef casIORef = IO.casIORef
modifyIORefCAS = IO.atomicModifyIORefCAS modifyIORefCAS = IO.atomicModifyIORefCAS
atomically = IO.atomically atomically = IO.atomically
newTVarConc = IO.newTVarIO
readTVarConc = IO.readTVarIO readTVarConc = IO.readTVarIO
-- | Label the current thread, if the given label is nonempty. -- | Label the current thread, if the given label is nonempty.
@ -852,6 +861,7 @@ instance MonadConc m => MonadConc (IsConc m) where
modifyIORefCAS r = toIsConc . modifyIORefCAS r modifyIORefCAS r = toIsConc . modifyIORefCAS r
modifyIORefCAS_ r = toIsConc . modifyIORefCAS_ r modifyIORefCAS_ r = toIsConc . modifyIORefCAS_ r
atomically = toIsConc . atomically . fromIsSTM atomically = toIsConc . atomically . fromIsSTM
newTVarConc = toIsConc . newTVarConc
readTVarConc = toIsConc . readTVarConc readTVarConc = toIsConc . readTVarConc
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -901,6 +911,7 @@ instance C => MonadConc (T m) where { \
modifyIORefCAS r = lift . modifyIORefCAS r ; \ modifyIORefCAS r = lift . modifyIORefCAS r ; \
modifyIORefCAS_ r = lift . modifyIORefCAS_ r ; \ modifyIORefCAS_ r = lift . modifyIORefCAS_ r ; \
atomically = lift . atomically ; \ atomically = lift . atomically ; \
newTVarConc = lift . newTVarConc ; \
readTVarConc = lift . readTVarConc } readTVarConc = lift . readTVarConc }
-- | New threads inherit the reader state of their parent, but do not -- | New threads inherit the reader state of their parent, but do not

View File

@ -2,7 +2,7 @@
-- documentation, see http://haskell.org/cabal/users-guide/ -- documentation, see http://haskell.org/cabal/users-guide/
name: concurrency name: concurrency
version: 1.8.0.0 version: 1.8.1.0
synopsis: Typeclasses, functions, and data types for concurrency and STM. synopsis: Typeclasses, functions, and data types for concurrency and STM.
description: description:
@ -32,7 +32,7 @@ source-repository head
source-repository this source-repository this
type: git type: git
location: https://github.com/barrucadu/dejafu.git location: https://github.com/barrucadu/dejafu.git
tag: concurrency-1.8.0.0 tag: concurrency-1.8.1.0
library library
exposed-modules: Control.Monad.Conc.Class exposed-modules: Control.Monad.Conc.Class

View File

@ -27,7 +27,7 @@ There are a few different packages under the Déjà Fu umbrella:
.. csv-table:: .. csv-table::
:header: "Package", "Version", "Summary" :header: "Package", "Version", "Summary"
":hackage:`concurrency`", "1.8.0.0", "Typeclasses, functions, and data types for concurrency and STM" ":hackage:`concurrency`", "1.8.1.0", "Typeclasses, functions, and data types for concurrency and STM"
":hackage:`dejafu`", "2.1.0.1", "Systematic testing for Haskell concurrency" ":hackage:`dejafu`", "2.1.0.1", "Systematic testing for Haskell concurrency"
":hackage:`hunit-dejafu`", "2.0.0.1", "Déjà Fu support for the HUnit test framework" ":hackage:`hunit-dejafu`", "2.0.0.1", "Déjà Fu support for the HUnit test framework"
":hackage:`tasty-dejafu`", "2.0.0.1", "Déjà Fu support for the tasty test framework" ":hackage:`tasty-dejafu`", "2.0.0.1", "Déjà Fu support for the tasty test framework"