[GHC] #9527: Add Generic instances for Language.Haskell.TH

#9527: Add Generic instances for Language.Haskell.TH -------------------------------------+------------------------------------- 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: 9526 | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Template Haskell has a number of huge data types that would be much easier to work with if they had `Generic` instances. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9527 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9527: Add Generic instances for Language.Haskell.TH -------------------------------------+------------------------------------- Reporter: nh2 | Owner: goldfire Type: feature | Status: new request | Milestone: 7.10.1 Priority: normal | Version: 7.8.3 Component: Core | Keywords: Libraries | Architecture: Unknown/Multiple Resolution: | Difficulty: Moderate (less Operating System: | than a day) Unknown/Multiple | Blocked By: 9526 Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by goldfire): * cc: core-libraries-committee@… (added) * owner: ekmett => goldfire Comment: I'm starting some TH work so will take this one. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9527#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9527: Add Generic instances for Language.Haskell.TH -------------------------------------+------------------------------------- Reporter: nh2 | Owner: goldfire Type: feature | Status: new request | Milestone: 7.10.1 Priority: normal | Version: 7.8.3 Component: Core | Keywords: Libraries | Architecture: Unknown/Multiple Resolution: | Difficulty: Moderate (less Operating System: | than a day) Unknown/Multiple | Blocked By: 9526 Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by luite): While you're at it, could you check if adding `Binary` instances is still problematic? The binary package is not a dependency at the moment. There's a comment in the code about switching to `Binary` (from `Data`) for serialization for annotations: http://git.haskell.org/packages/template- haskell.git/blob/9bcc122819a6f4a2ae7ad569717324b8368e801c:/Language/Haskell/TH/Syntax.hs#l661 Serialization of the other data types is useful for out-of-process TH currently used by GHCJS, possibly in the future for cross compilation (someone started porting the GHCJS code to GHC but appears to have stopped working on it, I hope i have time to pick this up soon) Using the default `Binary` instance based on the `GHC.Generics` is ok for this purpose and works for almost all types. Here is my list of orphan instances: https://github.com/ghcjs/ghcjs- prim/blob/915f263c06b7f4a246c6e02ecdf2b9a0550ed967/GHCJS/Prim/TH/Types.hs#L113-L166 `NameFlavour` requires a handwritten instance because of an `Int#` field. Can this be changed to a strict `Int` field? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9527#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9527: Add Generic instances for Language.Haskell.TH -------------------------------------+------------------------------------- Reporter: nh2 | Owner: goldfire Type: feature | Status: new request | Milestone: 7.10.1 Priority: normal | Version: 7.8.3 Component: Core | Keywords: Libraries | Architecture: Unknown/Multiple Resolution: | Difficulty: Moderate (less Operating System: | than a day) Unknown/Multiple | Blocked By: 9526 Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by goldfire): See [wiki:Design/TemplateHaskellGADTs] for a related change to the `Dec` type I'd like feedback on. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9527#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9527: Add Generic instances for Language.Haskell.TH -------------------------------------+------------------------------------- Reporter: nh2 | Owner: goldfire Type: feature | Status: new request | Milestone: 7.10.1 Priority: normal | Version: 7.8.3 Component: Core | Keywords: Libraries | Architecture: Unknown/Multiple Resolution: | Difficulty: Moderate (less Operating System: | than a day) Unknown/Multiple | Blocked By: 9526 Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by goldfire): An IRC discussion suggests not adding `Binary` instances: hvr 1:32 goldfire: well, we only recently dropped the containers dep in template-haskell to not force users wanting to use TH to a specific containers verison hvr 1:32 goldfire: adding dep on 'binary' would be rather undesirable in that respect goldfire 1:32 hvr: That makes sense. 1:33 hvr: Does this get mitigated at all by the Backpack work? hvr 1:33 goldfire: no idea tbh goldfire 1:33 Because my (very loose) understanding is that multiple versions of the same package can now coexist peacefully. 1:34 So, a TH client that doesn't use the Binary instances would be welcome to use a different version of the binary package. 1:34 But, a TH client that wanted to use the TH Binary instances would be tied to the specific version of binary that TH ships with, lest they get type errors. 1:35 ezyang: Care to comment on my and hvr's discussion just now? ezyang 1:46 goldfire, hvr: As with everything, this comes with the caveat that Cabal doesn't know how to handle this, but yes, in principle this is possible with the new change rwbarton 1:47 sounds like it would make sense to wait until 7.12 to add those instances goldfire 1:47 rwbarton: Yes, that's the conclusion I'm coming to. luite: Care to counter? rwbarton 1:48 since the out-of-process TH most likely won't land in 7.10 anyways right? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9527#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9527: Add Generic instances for Language.Haskell.TH -------------------------------------+------------------------------------- Reporter: nh2 | Owner: goldfire Type: feature | Status: patch request | Milestone: 7.10.1 Priority: normal | Version: 7.8.3 Component: Core | Keywords: Libraries | Architecture: Unknown/Multiple Resolution: | Difficulty: Moderate (less Operating System: | than a day) Unknown/Multiple | Blocked By: 9526 Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: Phab: D437 | -------------------------------------+------------------------------------- Changes (by goldfire): * status: new => patch * differential: => Phab: D437 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9527#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9527: Add Generic instances for Language.Haskell.TH -------------------------------------+------------------------------------- Reporter: nh2 | Owner: goldfire Type: feature | Status: patch request | Milestone: 7.10.1 Priority: normal | Version: 7.8.3 Component: Core | Keywords: Libraries | Architecture: Unknown/Multiple Resolution: | Difficulty: Moderate (less Operating System: | than a day) Unknown/Multiple | Blocked By: 9526 Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: Phab:D437 | -------------------------------------+------------------------------------- Changes (by goldfire): * differential: Phab: D437 => Phab:D437 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9527#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9527: Add Generic instances for Language.Haskell.TH
-------------------------------------+-------------------------------------
Reporter: nh2 | Owner: goldfire
Type: feature | Status: patch
request | Milestone: 7.10.1
Priority: normal | Version: 7.8.3
Component: Core | Keywords:
Libraries | Architecture: Unknown/Multiple
Resolution: | Difficulty: Moderate (less
Operating System: | than a day)
Unknown/Multiple | Blocked By: 9526
Type of failure: | Related Tickets:
None/Unknown |
Test Case: |
Blocking: |
Differential Revisions: Phab:D437 |
-------------------------------------+-------------------------------------
Comment (by Richard Eisenberg

#9527: Add Generic instances for Language.Haskell.TH
-------------------------------------+-------------------------------------
Reporter: nh2 | Owner: goldfire
Type: feature | Status: patch
request | Milestone: 7.10.1
Priority: normal | Version: 7.8.3
Component: Core | Keywords:
Libraries | Architecture: Unknown/Multiple
Resolution: | Difficulty: Moderate (less
Operating System: | than a day)
Unknown/Multiple | Blocked By: 9526
Type of failure: | Related Tickets:
None/Unknown |
Test Case: |
Blocking: |
Differential Revisions: Phab:D437 |
-------------------------------------+-------------------------------------
Comment (by Richard Eisenberg

#9527: Add Generic instances for Language.Haskell.TH -------------------------------------+------------------------------------- Reporter: nh2 | Owner: goldfire Type: feature | Status: closed request | Milestone: 7.10.1 Priority: normal | Version: 7.8.3 Component: Core | Keywords: Libraries | Architecture: Unknown/Multiple Resolution: fixed | Difficulty: Moderate (less Operating System: | than a day) Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | Differential Revisions: Phab:D437 | -------------------------------------+------------------------------------- Changes (by goldfire): * status: patch => closed * resolution: => fixed * blockedby: 9526 => -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9527#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9527: Add Generic instances for Language.Haskell.TH
-------------------------------------+-------------------------------------
Reporter: nh2 | Owner: goldfire
Type: feature | Status: closed
request | Milestone: 7.10.1
Priority: normal | Version: 7.8.3
Component: Core | Keywords:
Libraries | Architecture: Unknown/Multiple
Resolution: fixed | Difficulty: Moderate (less
Operating System: | than a day)
Unknown/Multiple | Blocked By:
Type of failure: | Related Tickets:
None/Unknown |
Test Case: |
Blocking: |
Differential Revisions: Phab:D437 |
-------------------------------------+-------------------------------------
Comment (by Richard Eisenberg

#9527: Add Generic instances for Language.Haskell.TH -------------------------------------+------------------------------------- Reporter: nh2 | Owner: goldfire Type: feature request | Status: closed Priority: normal | Milestone: 7.10.1 Component: Core Libraries | Version: 7.8.3 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): Phab:D437 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * keywords: => Generics -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9527#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC