Semigroup and Monoid instances for ST
In base-4.9
, a Monoid
instance for IO
was introduced. I would like to propose adding a similar instance for ST
. This should be even less controversial since there is only one meaningful Monoid
instance for ST
(it lacks the exception-catching facilities of IO
). The behavior of the Semigroup
and Monoid
instances would need to match this:
instance Monoid a => Monoid (ST s a) where
mappend = liftA2 mappend
mempty = pure mempty
This would let me use fold
and foldMap
over ST
computations, which would occasionally be useful.
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.2 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | low |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |