Skip to content

Commit fde7771

Browse files
nitinprakash96bolt12
authored andcommitted
MIN_VERSION macro + changelog
1 parent e0f27d5 commit fde7771

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

.github/workflows/checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Cheks
1+
name: Checks
22

33
on:
44
pull_request:

io-classes/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## next release
44

5+
### Non breaking change
6+
7+
* Add `writeTMVar` to `MonadSTM`.
8+
59
### Breaking changes
610

711
* `MonadST` depends on `PrimMonad`.

io-classes/src/Control/Monad/Class/MonadSTM/Internal.hs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE DataKinds #-}
23
{-# LANGUAGE DefaultSignatures #-}
34
{-# LANGUAGE DerivingStrategies #-}
@@ -571,7 +572,11 @@ instance MonadSTM IO where
571572
readTMVar = STM.readTMVar
572573
tryReadTMVar = STM.tryReadTMVar
573574
swapTMVar = STM.swapTMVar
575+
#if MIN_VERSION_stm(2, 5, 1)
574576
writeTMVar = STM.writeTMVar
577+
#else
578+
writeTMVar = writeTMVar'
579+
#endif
575580
isEmptyTMVar = STM.isEmptyTMVar
576581
newTQueue = STM.newTQueue
577582
readTQueue = STM.readTQueue
@@ -1245,3 +1250,10 @@ instance MonadSTM m => MonadSTM (ReaderT r m) where
12451250

12461251
(.:) :: (c -> d) -> (a -> b -> c) -> (a -> b -> d)
12471252
(f .: g) x y = f (g x y)
1253+
1254+
-- TODO: writeTMVar was introduced in stm-2.5.1. But io-sim supports stm older than that
1255+
-- Therefore this can be removed once we don't need backwards compatibility with stm.
1256+
#if !MIN_VERSION_stm(2,5,1)
1257+
writeTMVar' :: STM.TMVar a -> a -> STM.STM ()
1258+
writeTMVar' t new = STM.tryTakeTMVar t >> STM.putTMVar t new
1259+
#endif

0 commit comments

Comments
 (0)