From 0d16bb3b08bd1527f88d5363312574478e3f3a89 Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Fri, 4 Aug 2023 13:04:39 +0200 Subject: [PATCH] Make writeTVar more strict It needs to evaluate the argument to WHNF before passing it to `checkInvariant`. --- .../Control/Concurrent/Class/MonadSTM/Strict/TVar/Checked.hs | 2 +- strict-checked-vars/strict-checked-vars.cabal | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/strict-checked-vars/src/Control/Concurrent/Class/MonadSTM/Strict/TVar/Checked.hs b/strict-checked-vars/src/Control/Concurrent/Class/MonadSTM/Strict/TVar/Checked.hs index 8bcb27ada..4ff3f9bd3 100644 --- a/strict-checked-vars/src/Control/Concurrent/Class/MonadSTM/Strict/TVar/Checked.hs +++ b/strict-checked-vars/src/Control/Concurrent/Class/MonadSTM/Strict/TVar/Checked.hs @@ -105,7 +105,7 @@ readTVarIO :: MonadSTM m => StrictTVar m a -> m a readTVarIO = Strict.readTVarIO . tvar writeTVar :: (MonadSTM m, HasCallStack) => StrictTVar m a -> a -> STM m () -writeTVar v a = +writeTVar v !a = checkInvariant (invariant v a) $ Strict.writeTVar (tvar v) a diff --git a/strict-checked-vars/strict-checked-vars.cabal b/strict-checked-vars/strict-checked-vars.cabal index 352c5d538..6334a0f9f 100644 --- a/strict-checked-vars/strict-checked-vars.cabal +++ b/strict-checked-vars/strict-checked-vars.cabal @@ -1,6 +1,6 @@ cabal-version: 3.0 name: strict-checked-vars -version: 0.1.0.2 +version: 0.1.0.3 synopsis: Strict MVars and TVars with invariant checking for IO and IOSim