blob: 308ef88beebc9ddb845b813bb9b7de6fff13896e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
{-# LANGUAGE BlockArguments #-}
module Util
( stmChanges,
)
where
import UnliftIO.STM
stmChanges :: (Eq a) => STM a -> IO (STM a)
stmChanges mkX = do
x'T <- newTVarIO Nothing
pure do
x' <- readTVar x'T
x <- mkX
checkSTM (Just x /= x')
writeTVar x'T (Just x)
pure x
|