[GHC] #8656: Identical functions in Templeta Haskell

#8656: Identical functions in Templeta Haskell -------------------------------------------+------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Template Haskell | Version: 7.7 Keywords: | Operating System: Architecture: Unknown/Multiple | Unknown/Multiple Difficulty: Easy (less than 1 hour) | Type of failure: Blocked By: | None/Unknown Related Tickets: | Test Case: | Blocking: -------------------------------------------+------------------------------- I noticed that module `Language.Haskell.TH.Lib` in template-haskell library contains duplicate functions: {{{ global :: Name -> ExpQ global s = return (VarE s) varE :: Name -> ExpQ varE s = return (VarE s) }}} If this is intended it should be documented why it is so and I think it would be good to express one function in terms of another. If this is accidental we should just get rid of one function. I never used TH so I have no idea whether this is done on purpose or not, thus leaving it to devs more experienced with TH. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8656 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8656: Identical functions in Templeta Haskell -------------------------------+------------------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Template | Version: 7.7 Haskell | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Easy (less than 1 hour) Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | -------------------------------+------------------------------------------- Comment (by goldfire): My sense is that functions like `varE` (and even type synonyms like `ExpQ`) are present mainly to ease the implementation of the !DsMeta module. That module takes quotes (like `[| 1 + x |]`) and converts them into Core code (like `appE (appE (varE '+) (litE (integerL 1))) (varE 'x)`). So, even though `global` exists, it's really nice to have `varE` so that there is regularity in these monadic functions. (Each constructor, say, of `Exp` has a function counterpart defined in `Language.Haskell.TH.Lib`.) Whether or not it's useful to have `global` is another question. But, my thought is that it's best not to disrupt potential clients of that function. I agree that it's a little silly to have both of these functions, but it doesn't seem worth changing, to me. I'm also not sure how best to document this issue. My tendency would be toward closing this ticket as "wontfix", but I'll wait for someone to second my reasoning before doing so. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8656#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8656: Identical functions in Templeta Haskell -------------------------------+------------------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Template | Version: 7.7 Haskell | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Easy (less than 1 hour) Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | -------------------------------+------------------------------------------- Comment (by simonpj): I'm inclined to deprecate `global`. I'll do that. S -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8656#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8656: Identical functions in Template Haskell -------------------------------+------------------------------------------- Reporter: jstolarek | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Template | Version: 7.7 Haskell | Keywords: Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Easy (less than 1 hour) Unknown/Multiple | Blocked By: Type of failure: | Related Tickets: None/Unknown | Test Case: | Blocking: | -------------------------------+------------------------------------------- Comment (by jstolarek):
I'm also not sure how best to document this issue. This could be documenting by explaining why we keep two identical functions, eg. `varE` for consistency and `global` to maintain API compatibility with existing code. Next person to see these two identical functions would not spend their time trying to figure out why do we have duplicate code :-)
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8656#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8656: Identical functions in Template Haskell
-------------------------------+-------------------------------------------
Reporter: jstolarek | Owner:
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Template | Version: 7.7
Haskell | Keywords:
Resolution: fixed | Architecture: Unknown/Multiple
Operating System: | Difficulty: Easy (less than 1 hour)
Unknown/Multiple | Blocked By:
Type of failure: | Related Tickets:
None/Unknown |
Test Case: |
Blocking: |
-------------------------------+-------------------------------------------
Changes (by simonpj):
* status: new => closed
* resolution: => fixed
Comment:
OK I've deprecated `global`:
{{{
commit 6b485668ba22d4d78664866100a8ef2daf62ff89
Author: Simon Peyton Jones
---------------------------------------------------------------
6b485668ba22d4d78664866100a8ef2daf62ff89 Language/Haskell/TH/Lib.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Language/Haskell/TH/Lib.hs b/Language/Haskell/TH/Lib.hs index 2dfef30..b7a88d6 100644 --- a/Language/Haskell/TH/Lib.hs +++ b/Language/Haskell/TH/Lib.hs @@ -200,6 +200,8 @@ dyn :: String -> ExpQ dyn s = return (VarE (mkName s)) global :: Name -> ExpQ +{-# DEPRECATED global "Use varE instead" #-} +-- Trac #8656; I have no idea why this function is duplicated global s = return (VarE s) varE :: Name -> ExpQ }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8656#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC