Skip to content

Commit

Permalink
Merge pull request #431 from input-output-hk/coot/strictness
Browse files Browse the repository at this point in the history
More strict newTVarWithInvariant, newTVarWithInvariantIO and newMVarWithInvariant
  • Loading branch information
coot authored Aug 4, 2023
2 parents 4427205 + 0e2f101 commit c3fb129
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
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.2

* Make `newTVarWithInvariant`, `newTVarWithInvariantIO` and `newMVarWithInvariant` strict.

## 0.1.0.1

* Export `checkInvariant`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
Expand Down Expand Up @@ -99,7 +100,7 @@ newMVarWithInvariant :: (HasCallStack, MonadMVar m)
=> (a -> Maybe String)
-> a
-> m (StrictMVar m a)
newMVarWithInvariant inv a =
newMVarWithInvariant inv !a =
checkInvariant (inv a) $
StrictMVar inv <$> Strict.newMVar a

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

Expand Down Expand Up @@ -85,15 +86,15 @@ newTVarWithInvariant :: (MonadSTM m, HasCallStack)
=> (a -> Maybe String)
-> a
-> STM m (StrictTVar m a)
newTVarWithInvariant inv a =
newTVarWithInvariant inv !a =
checkInvariant (inv a) $
StrictTVar inv <$> Strict.newTVar a

newTVarWithInvariantIO :: (MonadSTM m, HasCallStack)
=> (a -> Maybe String)
-> a
-> m (StrictTVar m a)
newTVarWithInvariantIO inv a =
newTVarWithInvariantIO inv !a =
checkInvariant (inv a) $
StrictTVar inv <$> Strict.newTVarIO a

Expand Down
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.1
version: 0.1.0.2
synopsis:
Strict MVars and TVars with invariant checking for IO and IOSim

Expand Down

0 comments on commit c3fb129

Please sign in to comment.