[GHC] #14837: Semigroup and Monoid instances for ST

GHC ghc-devs at haskell.org
Wed Feb 21 20:07:07 UTC 2018


#14837: Semigroup and Monoid instances for ST
-------------------------------------+-------------------------------------
           Reporter:  andrewthad     |             Owner:  (none)
               Type:  feature        |            Status:  new
  request                            |
           Priority:  low            |         Milestone:
          Component:  Compiler       |           Version:  8.2.2
           Keywords:  base           |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 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.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14837>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list