summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleg Grenrus <oleg.grenrus@iki.fi>2021-12-19 14:56:33 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-02-28 07:14:04 -0500
commit38cb920e3c7bea7348a245c8602ea9562622f9cc (patch)
treee3fd7d634dd1fb3d2a10196765d8719fa621d9cb
parent0a80b43641c0b66ecdc6cf1d3ae08b002a0f270f (diff)
downloadhaskell-38cb920e3c7bea7348a245c8602ea9562622f9cc.tar.gz
Add Monoid a => Monoid (STM a) instance
-rw-r--r--libraries/base/GHC/Conc/Sync.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/libraries/base/GHC/Conc/Sync.hs b/libraries/base/GHC/Conc/Sync.hs
index 99df92daed..dbc81e1848 100644
--- a/libraries/base/GHC/Conc/Sync.hs
+++ b/libraries/base/GHC/Conc/Sync.hs
@@ -667,6 +667,14 @@ instance Monad STM where
m >>= k = bindSTM m k
(>>) = (*>)
+-- | @since 4.17.0.0
+instance Semigroup a => Semigroup (STM a) where
+ (<>) = liftA2 (<>)
+
+-- | @since 4.17.0.0
+instance Monoid a => Monoid (STM a) where
+ mempty = pure mempty
+
bindSTM :: STM a -> (a -> STM b) -> STM b
bindSTM (STM m) k = STM ( \s ->
case m s of