diff options
author | Oleg Grenrus <oleg.grenrus@iki.fi> | 2021-12-19 14:56:33 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-02-28 07:14:04 -0500 |
commit | 38cb920e3c7bea7348a245c8602ea9562622f9cc (patch) | |
tree | e3fd7d634dd1fb3d2a10196765d8719fa621d9cb | |
parent | 0a80b43641c0b66ecdc6cf1d3ae08b002a0f270f (diff) | |
download | haskell-38cb920e3c7bea7348a245c8602ea9562622f9cc.tar.gz |
Add Monoid a => Monoid (STM a) instance
-rw-r--r-- | libraries/base/GHC/Conc/Sync.hs | 8 |
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 |