[GHC] #16177: Rename Q (TExp a) to Code a

#16177: Rename Q (TExp a) to Code a -------------------------------------+------------------------------------- Reporter: mpickering | Owner: (none) Type: feature | Status: new request | Priority: normal | Milestone: Component: Template | Version: 8.6.3 Haskell | Keywords: | Operating System: Unknown/Multiple TypedTemplateHaskell | Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I propose that we modify the typed template haskell API so that quoting an expression of type `t` results in a value of type `Code t` rather than `Q (TExp a)` and the splice construct requires an argument of type `Code a` to produce a value of type `a`. The definition of `Code` is as follows. {{{ newtype Code a = Code (Q (TExp a)) }}} There are two good reasons to do this. 1. `Q (TExp a)` is ugly and leaks implementation details to the user. Using effects from the `Q` monad is unsafe and against the principle of staged programming. 2. Writing instances for `Q (TExp a)` is quite difficult. It's much easier when the newtype is defined but at the cost of constant wrapping and unwrapping. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16177 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16177: Rename Q (TExp a) to Code a -------------------------------------+------------------------------------- Reporter: mpickering | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 8.6.3 Resolution: | Keywords: | TypedTemplateHaskell 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 goldfire): This also (in reference to #16176) might be a ghc-proposal. What operations in the `Q` monad are unsafe? Surely not lookups. Perhaps you mean unsafe in the sense that they aren't reflected in typed TH? I'm really not sure. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16177#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16177: Rename Q (TExp a) to Code a -------------------------------------+------------------------------------- Reporter: mpickering | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 8.6.3 Resolution: | Keywords: | TypedTemplateHaskell 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 mpickering): Unsafe meaning that running a splice can fail in any manner. Under that definition there are a few unsafe operations `qAddTopDecls`, `qRunIO`, `qReport` come immediately to mind. The other `qReify*` operations should be discouraged as well as they go against how people should be writing their typed template haskell programs (in my opinion). Dispatching based of these I guess is possible in a safe manner but I'm not sure how you could do much usefully as you have to construct a `Name` in order to use them. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16177#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16177: Rename Q (TExp a) to Code a -------------------------------------+------------------------------------- Reporter: mpickering | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 8.6.3 Resolution: | Keywords: | TypedTemplateHaskell 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 goldfire): I still say this is best debated in a ghc-proposal. There are significant design/policy decisions here that will benefit from a broad audience. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16177#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#16177: Rename Q (TExp a) to Code a -------------------------------------+------------------------------------- Reporter: mpickering | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 8.6.3 Resolution: | Keywords: | TypedTemplateHaskell 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 mpickering): I agree with you Richard. I'll get around to it along with #16176. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16177#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC