From a48ddb86292f381d74e02d95bc962237dc8781f9 Mon Sep 17 00:00:00 2001 From: Jens Nolte <git@queezle.net> Date: Mon, 19 Sep 2022 01:04:54 +0200 Subject: [PATCH] Simplify writeTMVar --- Control/Concurrent/STM/TMVar.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Control/Concurrent/STM/TMVar.hs b/Control/Concurrent/STM/TMVar.hs index d6ba0ef..69dacab 100644 --- a/Control/Concurrent/STM/TMVar.hs +++ b/Control/Concurrent/STM/TMVar.hs @@ -151,8 +151,10 @@ swapTMVar (TMVar t) new = do -- | Non-blocking write of a new value to a 'TMVar' -- Puts if empty. Replaces if populated. +-- +-- @since 2.5.1 writeTMVar :: TMVar a -> a -> STM () -writeTMVar t new = tryTakeTMVar t >> putTMVar t new +writeTMVar (TMVar t) new = writeTVar t (Just new) -- |Check whether a given 'TMVar' is empty. isEmptyTMVar :: TMVar a -> STM Bool -- GitLab