[GHC] #9526: Add missing Generic instances in base

#9526: Add missing Generic instances in base -------------------------------------+------------------------------------- Reporter: nh2 | Owner: Type: feature request | Status: new Priority: normal | Milestone: 7.10.1 Component: libraries/base | Version: 7.8.3 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Moderate (less | Type of failure: than a day) | None/Unknown Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Most primitive types (`Int`, `Char`, etc.) have a GHC.Generics.Generic instance, but some are missing, such as `Integer` and the various `Word*` data types. We should consistently have instances for all primitive types offered by base, since they are required if you want to derive a Generic instance for any type that contains them. I boldly set the milestone to 7.10 because I naively assume this should be straightforward. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9526 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9526: Add missing Generic instances in base -------------------------------------+------------------------------------- Reporter: nh2 | Owner: dreixel Type: feature | Status: new request | Milestone: 7.10.1 Priority: normal | Version: 7.8.3 Component: | Keywords: libraries/base | Architecture: Unknown/Multiple Resolution: | Difficulty: Moderate (less Operating System: | than a day) Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: 9527 | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by dreixel): * owner: => dreixel -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9526#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9526: Add missing Generic instances in base -------------------------------------+------------------------------------- Reporter: nh2 | Owner: dreixel Type: feature | Status: new request | Milestone: 7.10.1 Priority: normal | Version: 7.8.3 Component: | Keywords: libraries/base | Architecture: Unknown/Multiple Resolution: | Difficulty: Moderate (less Operating System: | than a day) Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: 9527 | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by heisenbug): * cc: heisenbug (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9526#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9526: Add missing Generic instances in base -------------------------------------+------------------------------------- Reporter: nh2 | Owner: dreixel Type: feature | Status: new request | Milestone: 7.10.1 Priority: normal | Version: 7.8.3 Component: | Keywords: libraries/base | Architecture: Unknown/Multiple Resolution: | Difficulty: Moderate (less Operating System: | than a day) Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: 9527 | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by dreixel): Actually, I'm thinking that perhaps we should delete the existing `Generic` instances for base types. They don't really add much; the only thing I can think of is that you can find out the module and datatype name. Other than that, any generic function will still have to provide adhoc behaviour for types such as `Int`, because there is no generic behaviour for these base types. Also, this doesn't really block #9527, as far as I can see. You can derive `Generic` for a datatype that contains `Integer`, for example, which doesn't have a `Generic` instance. Things only fail when you try to use a generic function that does not have an instance for `Integer`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9526#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9526: Add missing Generic instances in base -------------------------------------+------------------------------------- Reporter: nh2 | Owner: dreixel Type: feature request | Status: new Priority: normal | Milestone: 8.0.1 Component: Core Libraries | Version: 7.8.3 Resolution: | 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 simonpj): * keywords: => Generics -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9526#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9526: Add missing Generic instances in base -------------------------------------+------------------------------------- Reporter: nh2 | Owner: dreixel Type: feature request | Status: closed Priority: normal | Milestone: Component: Core Libraries | Version: 7.8.3 Resolution: wontfix | 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): * status: new => closed * resolution: => wontfix Comment: I'm going to close this for the same reasons that I closed #10512. Please re-open if you feel strongly otherwise. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9526#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9526: Add missing Generic instances in base -------------------------------------+------------------------------------- Reporter: nh2 | Owner: dreixel Type: feature request | Status: closed Priority: normal | Milestone: Component: Core Libraries | Version: 7.8.3 Resolution: wontfix | 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: | -------------------------------------+------------------------------------- Comment (by nh2): I can't tell - I don't really understand the change; link in the ticket description of #9766 seems broken. Can you explain a bit what this change does, and how it affects this issue? Thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9526#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9526: Add missing Generic instances in base -------------------------------------+------------------------------------- Reporter: nh2 | Owner: dreixel Type: feature request | Status: closed Priority: normal | Milestone: Component: Core Libraries | Version: 7.8.3 Resolution: wontfix | Keywords: Generics Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #10512 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * related: => #10512 Comment: Sorry, my bad. I linked the wrong issue. It should be #10512, where `Generic` instances were proposed for `Int32` and `Word64`. The resolution of that issue is wontfix, and in GHC 8.0, the `Generic` instances for `Char`, `Float`, `Double`, and `Int` [https://ghc.haskell.org/trac/ghc/ticket/10512#comment:7 will be removed]. Pedro outlines the reasons for not including `Generic` instances for primitive types [https://ghc.haskell.org/trac/ghc/ticket/10512#comment:3 here]. Basically, `Generic` instances are intended for inspecting the structure of regular, structured algebraic data types until you get down to the "leaves" of a data structure. The leaves only require //ad hoc// instances of the base class, not of `Generic`. Moreover, the previous `Generic` instances base types were lying to users. Previously, we had something like this: {{{#!hs type Rep Char = D1 D_Char (C1 C_Char (S1 NoSelector (Rec0 Char)) }}} But according to the rules of how `Generic` operates, that would suggest that `data Char = Char Char`, which is absolutely not the case. To avoid this dishonesty, we decided to remove the offending instances altogether. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9526#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9526: Add missing Generic instances in base -------------------------------------+------------------------------------- Reporter: nh2 | Owner: dreixel Type: feature request | Status: closed Priority: normal | Milestone: Component: Core Libraries | Version: 7.8.3 Resolution: wontfix | Keywords: Generics Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #10512 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by nh2): I think you linked the right issue; I got to #9766 via the git commit you mentioned in #10512. What you say makes sense, and it does look like a better solution. I don't know if it addresses all issues that motivated this issue, but your comment at https://ghc.haskell.org/trac/ghc/ticket/10512#comment:7 suggests that it does. I'll try that out when GHC 8 is released with this change, and reopen if there's any remaining problem. Thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9526#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9526: Add missing Generic instances in base -------------------------------------+------------------------------------- Reporter: nh2 | Owner: dreixel Type: feature request | Status: closed Priority: normal | Milestone: Component: Core Libraries | Version: 7.8.3 Resolution: wontfix | Keywords: Generics Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #10512 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by Iceland_jack): See ticket:10512#comment:12. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9526#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC