File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
io-classes/src/Control/Monad/Class/MonadSTM
io-sim/src/Control/Monad/IOSim Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -1319,6 +1319,12 @@ deriving instance MonadSTM m => Monad (WrappedSTM t r m)
1319
1319
deriving instance MonadSTM m => Alternative (WrappedSTM t r m )
1320
1320
deriving instance MonadSTM m => MonadPlus (WrappedSTM t r m )
1321
1321
1322
+ instance ( Semigroup a , MonadSTM m ) => Semigroup (WrappedSTM t r m a ) where
1323
+ a <> b = (<>) <$> a <*> b
1324
+ instance ( Monoid a , MonadSTM m ) => Monoid (WrappedSTM t r m a ) where
1325
+ mempty = pure mempty
1326
+
1327
+
1322
1328
-- note: this (and the following) instance requires 'UndecidableInstances'
1323
1329
-- extension because it violates 3rd Paterson condition, however `STM m` will
1324
1330
-- resolve to a concrete type of kind (Type -> Type), and thus no larger than
Original file line number Diff line number Diff line change @@ -178,6 +178,12 @@ data SimA s a where
178
178
179
179
newtype STM s a = STM { unSTM :: forall r . (a -> StmA s r ) -> StmA s r }
180
180
181
+ instance Semigroup a => Semigroup (STM s a ) where
182
+ a <> b = (<>) <$> a <*> b
183
+
184
+ instance Monoid a => Monoid (STM s a ) where
185
+ mempty = pure mempty
186
+
181
187
runSTM :: STM s a -> StmA s a
182
188
runSTM (STM k) = k ReturnStm
183
189
You can’t perform that action at this time.
0 commit comments