[GHC] #8797: Generics instances for monoid and applicative newtypes

#8797: Generics instances for monoid and applicative newtypes -------------------------------------------+------------------------------- Reporter: jcristovao | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: libraries/base | Version: 7.6.3 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Easy (less than 1 hour) | Type of failure: Blocked By: | None/Unknown Related Tickets: | Test Case: | Blocking: -------------------------------------------+------------------------------- Hi, Is there any particular reason why there aren't Generic instances for the newtypes under Data.Monoid and Control.Applicative (for example)? I've tried adding them to GHC/Generics.hs and base compiles without problems. Could this addition be considered? Best Regards, João -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8797 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8797: Generics instances for monoid and applicative newtypes -------------------------------+------------------------------------------- Reporter: jcristovao | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.6.3 Component: | Keywords: libraries/base | Architecture: Unknown/Multiple Resolution: | Difficulty: Easy (less than 1 hour) Operating System: | Blocked By: Unknown/Multiple | Related Tickets: Type of failure: | None/Unknown | Test Case: | Blocking: | -------------------------------+------------------------------------------- Comment (by dreixel): `StandaloneDeriving` can be used to get these instances in user code, but I don't see a reason why they shouldn't be provided directly where the type is defined. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8797#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8797: Generics instances for monoid and applicative newtypes -------------------------------+------------------------------------------- Reporter: jcristovao | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.6.3 Component: | Keywords: libraries/base | Architecture: Unknown/Multiple Resolution: | Difficulty: Easy (less than 1 hour) Operating System: | Blocked By: Unknown/Multiple | Related Tickets: Type of failure: | None/Unknown | Test Case: | Blocking: | -------------------------------+------------------------------------------- Changes (by simonpj): * cc: ekmett@… (added) Comment: I guess this is a library issue. Edward and the core library committee, over to you. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8797#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8797: Generics instances for monoid and applicative newtypes -------------------------------+------------------------------------------- Reporter: jcristovao | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.6.3 Component: | Keywords: libraries/base | Architecture: Unknown/Multiple Resolution: | Difficulty: Easy (less than 1 hour) Operating System: | Blocked By: Unknown/Multiple | Related Tickets: Type of failure: | None/Unknown | Test Case: | Blocking: | -------------------------------+------------------------------------------- Comment (by jcristovao): ```StandaloneDeriving``` can be used Yes, of course, but there is always the (increased) risk of two libraries using it, and thus having ```Duplicate instance declarations```. I would say its safer to include this in base. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8797#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8797: Generics instances for monoid and applicative newtypes -------------------------------+------------------------------------------- Reporter: jcristovao | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.6.3 Component: | Keywords: libraries/base | Architecture: Unknown/Multiple Resolution: | Difficulty: Easy (less than 1 hour) Operating System: | Blocked By: Unknown/Multiple | Related Tickets: Type of failure: | None/Unknown | Test Case: | Blocking: | -------------------------------+------------------------------------------- Comment (by ekmett): I personally have no objection and think it'd be a good idea. The `Generic` and `Generic1` instances clearly belong with their definitions. They also deserve `Typeable` and `Data`. Forcing the user to supply them risks conflicting orphans, making Haskell libraries less composable and there is no real data hiding argument to be made about transparent newtypes from base. I'll definitely put it to the committee and see what they think. In particular, while these 4 seem pretty obvious to me, there are some data types in there that could really use a few other instances as well. e.g. the fact that there is no `instance Num a => Num (Sum a)` or `instance Num a => Num (Product a)` is something I hear fairly regular complaints about in #haskell and none of the various reimplementations on hackage do anything but the obvious. Those start to speak to changing the suggested usage of these monoidal wrappers from something you 'put on long enough to foldMap' to something your data might live in long-term, but looking around that is what folks are actually doing. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8797#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8797: Generics instances for monoid and applicative newtypes -------------------------------+------------------------------------------- Reporter: jcristovao | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.6.3 Component: | Keywords: libraries/base | Architecture: Unknown/Multiple Resolution: | Difficulty: Easy (less than 1 hour) Operating System: | Blocked By: Unknown/Multiple | Related Tickets: Type of failure: | None/Unknown | Test Case: | Blocking: | -------------------------------+------------------------------------------- Comment (by ekmett): FWIW- The committee is in favor of adding the `Generic`, `Generic1`, `Data` and `Typeable` instances along with `Num` for `Sum` and `Product`. Do we want to try to pester Austin at the 11th hour to add them to the 7.8 release candidate or hold off a year for 7.10? The former has the benefit of, well, being a year sooner, but it may be that that ship has already sailed. Moreover, it'd means you can't write code that needs those instances and which works with both the 7.8.1-release candidates and the final release. On the other hand, once we have 7.8.1 the release candidates will have done their job and will be a non-issue. At this point I defer to Austin about the viability of packaging it up now or if we should wait. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8797#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8797: Generics instances for monoid and applicative newtypes -------------------------------+------------------------------------------- Reporter: jcristovao | Owner: Type: feature | Status: new request | Milestone: Priority: normal | Version: 7.6.3 Component: | Keywords: libraries/base | Architecture: Unknown/Multiple Resolution: | Difficulty: Easy (less than 1 hour) Operating System: | Blocked By: Unknown/Multiple | Related Tickets: Type of failure: | None/Unknown | Test Case: | Blocking: | -------------------------------+------------------------------------------- Comment (by thoughtpolice): After reviewing with Edward, these changes are so trivial and obvious that I'll push them in with a small set of patches today. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8797#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8797: Generics instances for monoid and applicative newtypes -------------------------------+------------------------------------------- Reporter: jcristovao | Owner: Type: feature | Status: new request | Milestone: 7.8.1 Priority: normal | Version: 7.8.1-rc1 Component: | Keywords: libraries/base | Architecture: Unknown/Multiple Resolution: | Difficulty: Easy (less than 1 hour) Operating System: | Blocked By: Unknown/Multiple | Related Tickets: Type of failure: | None/Unknown | Test Case: | Blocking: | -------------------------------+------------------------------------------- Changes (by thoughtpolice): * version: 7.6.3 => 7.8.1-rc1 * milestone: => 7.8.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8797#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8797: Generics instances for monoid and applicative newtypes
-------------------------------+-------------------------------------------
Reporter: jcristovao | Owner:
Type: feature | Status: new
request | Milestone: 7.8.1
Priority: normal | Version: 7.8.1-rc1
Component: | Keywords:
libraries/base | Architecture: Unknown/Multiple
Resolution: | Difficulty: Easy (less than 1 hour)
Operating System: | Blocked By:
Unknown/Multiple | Related Tickets:
Type of failure: |
None/Unknown |
Test Case: |
Blocking: |
-------------------------------+-------------------------------------------
Comment (by Austin Seipp

#8797: Generics instances for monoid and applicative newtypes -------------------------------+------------------------------------------- Reporter: jcristovao | Owner: Type: feature | Status: merge request | Milestone: 7.8.1 Priority: normal | Version: 7.8.1-rc1 Component: | Keywords: libraries/base | Architecture: Unknown/Multiple Resolution: | Difficulty: Easy (less than 1 hour) Operating System: | Blocked By: Unknown/Multiple | Related Tickets: Type of failure: | None/Unknown | Test Case: | Blocking: | -------------------------------+------------------------------------------- Changes (by thoughtpolice): * status: new => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8797#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8797: Generics instances for monoid and applicative newtypes -------------------------------+------------------------------------------- Reporter: jcristovao | Owner: Type: feature | Status: merge request | Milestone: 7.8.1 Priority: normal | Version: 7.8.1-rc1 Component: | Keywords: libraries/base | Architecture: Unknown/Multiple Resolution: | Difficulty: Easy (less than 1 hour) Operating System: | Blocked By: Unknown/Multiple | Related Tickets: Type of failure: | None/Unknown | Test Case: | Blocking: | -------------------------------+------------------------------------------- Comment (by jcristovao): I'm _very_ glad that this is being pushed to 7.8. Really good news. For my particular use case these are good enough, but if I might push the envelop, why stop here? I'm certain some modules are more dificult than others, due to dependency cycles, but (and withouth checking for that, just from a quick round up), why not include these: Control.Arrow: Kleisli, ArrowMonad Data.Fixed: Fixed, E0, E1, ... Data.Unique: Unique Data.Traversable: StateL, StateR, Id Data.Ord: Down System.Timeout: Timeout Also for Generic, Generic1, Data. If easy enough (i.e., no hard dependencies), it might be useful to someone else. Just a though, Thanks -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8797#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8797: Generics instances for monoid and applicative newtypes -------------------------------+------------------------------------------- Reporter: jcristovao | Owner: Type: feature | Status: merge request | Milestone: 7.8.1 Priority: normal | Version: 7.8.1-rc1 Component: | Keywords: libraries/base | Architecture: Unknown/Multiple Resolution: | Difficulty: Easy (less than 1 hour) Operating System: | Blocked By: Unknown/Multiple | Related Tickets: Type of failure: | None/Unknown | Test Case: | Blocking: | -------------------------------+------------------------------------------- Comment (by thoughtpolice): We should open a separate ticket for these I think. Edward I'm sure will agree that we need to look out for adding more sensible instances for the types in base (we always seem to forget some, somewhere). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8797#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8797: Generics instances for monoid and applicative newtypes -------------------------------+------------------------------------------- Reporter: jcristovao | Owner: Type: feature | Status: closed request | Milestone: 7.8.1 Priority: normal | Version: 7.8.1-rc1 Component: | Keywords: libraries/base | Architecture: Unknown/Multiple Resolution: fixed | Difficulty: Easy (less than 1 hour) Operating System: | Blocked By: Unknown/Multiple | Related Tickets: Type of failure: | None/Unknown | Test Case: | Blocking: | -------------------------------+------------------------------------------- Changes (by thoughtpolice): * status: merge => closed * resolution: => fixed Comment: Merged in 7.8 for RC2. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8797#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8797: Generics instances for monoid and applicative newtypes
-------------------------------+-------------------------------------------
Reporter: jcristovao | Owner:
Type: feature | Status: closed
request | Milestone: 7.8.1
Priority: normal | Version: 7.8.1-rc1
Component: | Keywords:
libraries/base | Architecture: Unknown/Multiple
Resolution: fixed | Difficulty: Easy (less than 1 hour)
Operating System: | Blocked By:
Unknown/Multiple | Related Tickets:
Type of failure: |
None/Unknown |
Test Case: |
Blocking: |
-------------------------------+-------------------------------------------
Comment (by Herbert Valerio Riedel

#8797: Generics instances for monoid and applicative newtypes -------------------------------------+------------------------------------- Reporter: jcristovao | Owner: Type: feature request | Status: closed Priority: normal | Milestone: 7.8.1 Component: libraries/base | Version: 7.8.1-rc1 Resolution: fixed | Keywords: Generics 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: => Generics -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8797#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC