Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export checkInvariant from strict-checked-vars #429

Merged
merged 2 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ jobs:
MSYSTEM: MINGW64
run: cabal test all --enable-tests --test-show-details=direct -j1

- name: Build strict-checked-vars with invariants
run: cabal build -f+checktvarinvariants -f+checkmvarinvariants strict-checked-vars
coot marked this conversation as resolved.
Show resolved Hide resolved

- uses: actions/upload-artifact@v3
with:
name: Build & test logs
Expand Down
4 changes: 4 additions & 0 deletions strict-checked-vars/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Revision history of strict-checked-vars

## 0.1.0.1

* Export `checkInvariant`.

## 0.1.0.0

* Initial version, not released on Hackage.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ module Control.Concurrent.Class.MonadMVar.Strict.Checked (
, tryTakeMVar
, withMVar
, withMVarMasked
-- * Invariant
, checkInvariant
-- * Re-exports
, MonadMVar
) where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ module Control.Concurrent.Class.MonadMVar.Strict.Checked.Switch (
, tryTakeMVar
, withMVar
, withMVarMasked
-- * Invariant
, checkInvariant
-- * Re-exports
, MonadMVar
) where

#if CHECK_MVAR_INVARIANTS
import qualified Control.Concurrent.Class.MonadMVar.Strict.Checked as StrictMVar.Checked
import Control.Concurrent.Class.MonadMVar.Strict.Checked hiding (newMVarWithInvariant, newEmptyMVarWithInvariant)
import Control.Concurrent.Class.MonadMVar.Strict.Checked hiding (checkInvariant, newMVarWithInvariant, newEmptyMVarWithInvariant)
#else
import qualified Control.Concurrent.Class.MonadMVar.Strict as StrictMVar
import Control.Concurrent.Class.MonadMVar.Strict
Expand All @@ -55,4 +57,11 @@ newMVarWithInvariant :: (HasCallStack, MonadMVar m)
newMVarWithInvariant = StrictMVar.Checked.newMVarWithInvariant
#else
newMVarWithInvariant _ = StrictMVar.newMVar
#endif

checkInvariant :: HasCallStack => Maybe String -> a -> a
#if CHECK_MVAR_INVARIANTS
checkInvariant = StrictMVar.Checked.checkInvariant
#else
checkInvariant = \_ a -> a
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ module Control.Concurrent.Class.MonadSTM.Strict.TVar.Checked (
-- * MonadTraceSTM
, traceTVar
, traceTVarIO
-- * Invariant
, checkInvariant
) where

import Control.Concurrent.Class.MonadSTM (InspectMonad,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ module Control.Concurrent.Class.MonadSTM.Strict.TVar.Checked.Switch (
-- * MonadTraceSTM
, traceTVar
, traceTVarIO
-- * invariant
, checkInvariant
) where

import Control.Concurrent.Class.MonadSTM (MonadSTM, STM)
#if CHECK_TVAR_INVARIANTS
import qualified Control.Concurrent.Class.MonadSTM.Strict.TVar.Checked as StrictTVar.Checked
import Control.Concurrent.Class.MonadSTM.Strict.TVar.Checked hiding (newTVarWithInvariant, newTVarWithInvariantIO)
import Control.Concurrent.Class.MonadSTM.Strict.TVar.Checked hiding (checkInvariant, newTVarWithInvariant, newTVarWithInvariantIO)
#else
import qualified Control.Concurrent.Class.MonadSTM.Strict.TVar as StrictTVar
import Control.Concurrent.Class.MonadSTM.Strict.TVar
Expand All @@ -53,4 +55,11 @@ newTVarWithInvariantIO :: (MonadSTM m, HasCallStack)
newTVarWithInvariantIO = StrictTVar.Checked.newTVarWithInvariantIO
#else
newTVarWithInvariantIO _ = StrictTVar.newTVarIO
#endif

checkInvariant :: HasCallStack => Maybe String -> a -> a
#if CHECK_TVAR_INVARIANTS
checkInvariant = StrictTVar.Checked.checkInvariant
#else
checkInvariant = \_ a -> a
#endif
2 changes: 1 addition & 1 deletion strict-checked-vars/strict-checked-vars.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 3.0
name: strict-checked-vars
version: 0.1.0.0
version: 0.1.0.1
synopsis:
Strict MVars and TVars with invariant checking for IO and IOSim

Expand Down