diff options
author | Alexander Foremny <aforemny@posteo.de> | 2024-04-10 14:05:08 +0200 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2024-04-26 14:08:57 +0200 |
commit | ea2a725e9d5d758495b556631c3280de9d97fa0a (patch) | |
tree | 374e4ba40d4c5a4cca87a1cf34733a53bbf0c491 /app/Util.hs |
init
Diffstat (limited to 'app/Util.hs')
-rw-r--r-- | app/Util.hs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/Util.hs b/app/Util.hs new file mode 100644 index 0000000..308ef88 --- /dev/null +++ b/app/Util.hs @@ -0,0 +1,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 |