[GHC] #11081: Implement Introspective Template Haskell

#11081: Implement Introspective Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: feature | Status: new request | Priority: normal | Milestone: ⊥ Component: Template | Version: 7.10.2 Haskell | 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: | TemplateHaskell/Introspective -------------------------------------+------------------------------------- This ticket is to track commentary and reactions to TemplateHaskell/Introspective, and to help the proposal not get lost. Contrary to the title of this ticket, it is not yet resolved that Introspective Template Haskell should ever be implemented. But with some of the support that it's gotten, it seemed appropriate to make a ticket. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11081 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11081: Implement Introspective Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: feature request | Status: new Priority: normal | Milestone: ⊥ Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | TemplateHaskell/Introspective | -------------------------------------+------------------------------------- Changes (by jstolarek): * cc: jstolarek (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11081#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11081: Implement Introspective Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: feature request | Status: new Priority: normal | Milestone: ⊥ Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | TemplateHaskell/Introspective | -------------------------------------+------------------------------------- Changes (by lerkok): * cc: lerkok (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11081#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11081: Implement Introspective Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: feature request | Status: new Priority: normal | Milestone: ⊥ Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | TemplateHaskell/Introspective | -------------------------------------+------------------------------------- Comment (by lerkok): I think this is a great idea. In the past, I've tried both TH and haskell- src-exts to do relatively simple things, but ended-up abandoning them due to the inherent complexity of source level haskell that had very little to do with what I really cared about. Being able to get your hands on Core at the regular Haskell level would truly simplify life, and I suspect would open the flood-gates for a lot of people to develop extremely useful artifacts, making the GHC/Haskell experience even better. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11081#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11081: Implement Introspective Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: feature request | Status: new Priority: normal | Milestone: ⊥ Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | TemplateHaskell/Introspective | -------------------------------------+------------------------------------- Changes (by gridaphobe): * cc: gridaphobe (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11081#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11081: Implement Introspective Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: feature request | Status: new Priority: normal | Milestone: ⊥ Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | TemplateHaskell/Introspective | -------------------------------------+------------------------------------- Comment (by simonpj): I'm sceptical about the stuff about Core until I see more details. But that's for the future. The fundamental idea here is to replace `Language.Haskell.TH.Syntax` outright with `HsSyn`. The advantages, of course, are (a) avoiding duplication, (b) TH stop lagging GHC. The disadvantage is that `HsSyn` is designed as an internal data type for a compiler. We feel free to * decorate it with extra information (mostly types) as it moves down the pipeline, * have one constructor before type checking and a different one afterwards (eg `ConPatIn` and `ConPatOut` in `HsPat` * add elaboration info for type and dictionary applications and instantiation. For TH programs that construct syntax trees directly (ie not using quotation) or pattern-match over them, all this extra clutter might be confusing and/or awkward. I'm very unsure about the back-compat shim, but maybe it's possible. Yay for pattern synonyms. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11081#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11081: Implement Introspective Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: feature request | Status: new Priority: normal | Milestone: ⊥ Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | TemplateHaskell/Introspective | -------------------------------------+------------------------------------- Changes (by alanz): * cc: alanz (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11081#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11081: Implement Introspective Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: feature request | Status: new Priority: normal | Milestone: ⊥ Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | TemplateHaskell/Introspective | -------------------------------------+------------------------------------- Comment (by Iceland_jack): Replying to [comment:5 simonpj]:
I'm very unsure about the back-compat shim, but maybe it's possible. Yay for pattern synonyms.
Could they also be used for other [https://ghc.haskell.org/trac/ghc/wiki/Migration/8.0?action=diff&version=42 migrations]? In [https://hackage.haskell.org/package/template- haskell-2.11.0.0/docs/Language-Haskell-TH-Lib.html#v:instanceD Language.Haskell.TH.Lib] another function `instanceWithOverlapD` was added to prevent breakage: {{{#!hs instanceD :: CxtQ -> TypeQ -> [DecQ] -> DecQ instanceWithOverlapD :: Maybe Overlap -> CxtQ -> TypeQ -> [DecQ] -> DecQ }}} The same could have been done with `InstanceD` {{{#!hs -- OLD: -- | InstanceD Cxt Type [Dec] | InstanceWithOverlapD (Maybe Overlap) Cxt Type [Dec] }}} and like `ErrorCall` defining {{{#!hs pattern InstanceD :: Ctx -> Type -> [Dec] -> Dec pattern InstanceD ctx ty decs = InstanceWithOverlapD Nothing ctx ty decs }}} which suffers from the [ticket:8779#comment:12 same problem] as `ErrorCall`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11081#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11081: Implement Introspective Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: feature request | Status: new Priority: normal | Milestone: ⊥ Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | TemplateHaskell/Introspective | -------------------------------------+------------------------------------- Comment (by simonmar): Can this be made to work with `-fexternal-interpreter`? I was hoping to make that the default at some point in the future. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11081#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11081: Implement Introspective Template Haskell -------------------------------------+------------------------------------- Reporter: goldfire | Owner: Type: feature request | Status: new Priority: normal | Milestone: ⊥ Component: Template Haskell | Version: 7.10.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | TemplateHaskell/Introspective | -------------------------------------+------------------------------------- Comment (by goldfire): I think so, yes. Shayan Najd is currently completing a Summer of Haskell project (https://summer.haskell.org/) in an attempt to combine haskell- src-exts, GHC's `HsSyn`, and the TH AST. Serializability is a consideration, and so this should all be OK. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11081#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC