[GHC] #14107: Implement Semigroup and Monoid instances for the ST monad

#14107: Implement Semigroup and Monoid instances for the ST monad -------------------------------------+------------------------------------- Reporter: plato | Owner: (none) Type: feature | Status: new request | Priority: normal | Milestone: Component: Core | Version: 8.2.1 Libraries | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Since IO implements `Semigroup` and `Monoid`, is there a good reason for `ST` not to implement those, too? I discovered the lack of those instances while using `foldMap` for code that used to use `IO` as the underlying monad. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14107 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14107: Implement Semigroup and Monoid instances for the ST monad -------------------------------------+------------------------------------- Reporter: plato | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.2.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * keywords: => newcomer Comment: Replying to [ticket:14107 plato]:
Since IO implements `Semigroup` and `Monoid`, is there a good reason for `ST` not to implement those, too?
The reason is because no one has asked for them yet :) I'd have no issues with a patch that implemented this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14107#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14107: Implement Semigroup and Monoid instances for the ST monad -------------------------------------+------------------------------------- Reporter: plato | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.2.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by plato): Okay, I'll try to create one! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14107#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14107: Implement Semigroup and Monoid instances for the ST monad -------------------------------------+------------------------------------- Reporter: plato | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.2.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by plato): I dug into the source code and have two questions: 1. Adding the `Monoid` and `Semigroup` instances was simple enough, but I noticed some instances have a `since` annotation. Should I add one, too? If so, which version should I add? 2. I tested this by recompiling ghc, running `ghc-stage2` interactively and typing `:info ST`, which printed the correct instances. I also ran `./validate`. Are there any other tests I shall perform for this kind of feature? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14107#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14107: Implement Semigroup and Monoid instances for the ST monad -------------------------------------+------------------------------------- Reporter: plato | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 8.2.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): 1. Yes, I'd add `@since: 4.11.0.0`, since that will be the next major version of `base`. 2. If it passes `./validate`, then I'd say it works! Do note that when you submit a patch via [https://phabricator.haskell.org/ Phabricator], the Harbormaster CI machines will also run `./validate` against your changes as an additional sanity-check. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14107#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14107: Implement Semigroup and Monoid instances for the ST monad -------------------------------------+------------------------------------- Reporter: plato | Owner: (none) Type: feature request | Status: patch Priority: normal | Milestone: Component: Core Libraries | Version: 8.2.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3845 Wiki Page: | -------------------------------------+------------------------------------- Changes (by plato): * status: new => patch * differential: => Phab:D3845 Comment: I added a differential on phabricator. Everything seems to work on Windows, Linux, and OSX. See here: https://phabricator.haskell.org/B17099 I hope I got the "Differential Rev(s)" format right. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14107#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14107: Implement Semigroup and Monoid instances for the ST monad
-------------------------------------+-------------------------------------
Reporter: plato | Owner: (none)
Type: feature request | Status: patch
Priority: normal | Milestone:
Component: Core Libraries | Version: 8.2.1
Resolution: | Keywords: newcomer
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D3845
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#14107: Implement Semigroup and Monoid instances for the ST monad -------------------------------------+------------------------------------- Reporter: plato | Owner: (none) Type: feature request | Status: closed Priority: normal | Milestone: 8.4.1 Component: Core Libraries | Version: 8.2.1 Resolution: fixed | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3845 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => closed * resolution: => fixed * milestone: => 8.4.1 Comment: Thanks plato! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14107#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC