[GHC] #10902: Refactor type families in Template Haskell

#10902: Refactor type families in Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: task | Status: new Priority: normal | Milestone: 8.0.1 Component: Template | Version: 7.11 Haskell | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | -------------------------------------+------------------------------------- I see that we now have `OpenTypeFamilyD` and `ClosedTypeFamilyD` in Template Haskell. These constructors have quite a lot in common, and I think it's worth having a `TypeFamilyHead` datatype that contains the bits in common. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10902 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10902: Refactor type families in Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: task | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by jstolarek): * cc: jstolarek (added) * keywords: => newcomer -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10902#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10902: Refactor type families in Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: task | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 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 osa1): * cc: osa1 (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10902#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10902: Refactor type families in Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: johnleo Type: task | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 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 johnleo): * owner: => johnleo -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10902#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10902: Refactor type families in Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: johnleo Type: task | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 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 johnleo): Proposal: In `ghc/libraries/template-haskell/Language/Haskell/TH/Syntax.hs` create a new data type: {{{#!hs data TypeFamilyBase = TypeFamilyBase Name [TyVarBndr] FamilyResultSig (Maybe InjectivityAnn) }}} In `data Dec` in the same file replace the definitions of `OpenTypeFamilyD` and `ClosedTypeFamilyD` with the following: {{{#!hs | OpenTypeFamilyD TypeFamilyBase | ClosedTypeFamilyD TypeFamilyBase [TySynEqn] }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10902#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10902: Refactor type families in Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: johnleo Type: task | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 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 jstolarek): That looks good. Although I would prefer the new data type to be called `TypeFamilyHead` (as Richard proposed) rather than `TypeFamilyBase`. I find it more intuitive - after all the new data type stores the contents of type family head! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10902#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10902: Refactor type families in Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: johnleo Type: task | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 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 johnleo): Sure, `TypeFamilyHead` is fine. I wasn't sure what the standard GHC convention is, and "base" would be more typical for a "base type". Is "type family head" mentioned somewhere in other source code or documentation? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10902#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10902: Refactor type families in Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: johnleo Type: task | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 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 jstolarek):
Is "type family head" mentioned somewhere in other source code or documentation?
Yes, I think it's a commonly used term. For example, you can take a look at [https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/type- families.html type family section in the User's Guide]. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10902#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10902: Refactor type families in Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: johnleo Type: task | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 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 johnleo): Thanks for the pointer. From what I can tell the term "head" is defined in the original paper //Type classes: an exploration of the design space// for type class instances: Given {{{#!hs instance P => C T_1 ... T_n where ... }}} they define the head to be the part `C T_1 ... T_n` between `=>` and `where`. They also use it without precise definition to refer to the "class head" where again it looks like they are referring to the part between `=>` and `where` of a type class declaration. These seem to be the only two usages of head in sections 7.6 and 7.7 of the GHC user manual. However by analogy it does seem that naming the part between `type family` and `where` as the "head" of a type family declaration would be appropriate. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10902#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10902: Refactor type families in Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: johnleo Type: task | Status: new Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 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): * cc: RyanGlScott (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10902#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10902: Refactor type families in Template Haskell
-------------------------------------+-------------------------------------
Reporter: goldfire | Owner: johnleo
Type: task | Status: new
Priority: normal | Milestone: 8.0.1
Component: Template Haskell | Version: 7.11
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 Ben Gamari

#10902: Refactor type families in Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: johnleo Type: task | Status: closed Priority: normal | Milestone: 8.0.1 Component: Template Haskell | Version: 7.11 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): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10902#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC