Skip to content

Commit

Permalink
MIN_VERSION macro + changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
nitinprakash96 committed May 11, 2024
1 parent 32a6893 commit 8d18ca4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Cheks
name: Checks

on:
pull_request:
Expand Down
4 changes: 4 additions & 0 deletions io-classes/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## next release

### Non breaking change

* Add `writeTMVar` to `MonadSTM`.

### Breaking changes

* `MonadST` depends on `PrimMonad`.
Expand Down
12 changes: 12 additions & 0 deletions io-classes/src/Control/Monad/Class/MonadSTM/Internal.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DefaultSignatures #-}
{-# LANGUAGE DerivingStrategies #-}
Expand Down Expand Up @@ -571,7 +572,11 @@ instance MonadSTM IO where
readTMVar = STM.readTMVar
tryReadTMVar = STM.tryReadTMVar
swapTMVar = STM.swapTMVar
#if MIN_VERSION_stm(2, 5, 1)
writeTMVar = STM.writeTMVar
#else
writeTMVar = writeTMVar'
#endif
isEmptyTMVar = STM.isEmptyTMVar
newTQueue = STM.newTQueue
readTQueue = STM.readTQueue
Expand Down Expand Up @@ -1245,3 +1250,10 @@ instance MonadSTM m => MonadSTM (ReaderT r m) where

(.:) :: (c -> d) -> (a -> b -> c) -> (a -> b -> d)
(f .: g) x y = f (g x y)

-- TODO: writeTMVar was introduced in stm-2.5.1. But io-sim supports stm older than that
-- Therefore this can be removed once we don't need backwards compatibility with stm.
#if !MIN_VERSION_stm(2,5,1)
writeTMVar' :: STM.TMVar a -> a -> STM.STM ()
writeTMVar' t new = STM.tryTakeTMVar t >> STM.putTMVar t new
#endif

0 comments on commit 8d18ca4

Please sign in to comment.