[GHC] #13961: TH.reify can be ambiguous when giving a name that's in multiple namespaces

#13961: TH.reify can be ambiguous when giving a name that's in multiple namespaces -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Template | Version: 8.0.1 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: -------------------------------------+------------------------------------- What should this program do? {{{#!hs {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeOperators #-} module Bug where import Language.Haskell.TH (***) :: Bool -> Bool -> Bool (***) _ _ = True type (***) a b = Bool $(return []) main :: IO () main = putStrLn $(reify (mkName "***") >>= stringE . show) }}} The issue is that `reify (mkName "***")` could conceivable look up the `Info` of two different things: the value-level `(***)` or the type-level `(***)`. In this case, it happens to pick the value-level one: {{{ $ /opt/ghc/8.2.1/bin/runghc Bug.hs VarI Bug.*** (AppT (AppT ArrowT (ConT GHC.Types.Bool)) (AppT (AppT ArrowT (ConT GHC.Types.Bool)) (ConT GHC.Types.Bool))) Nothing }}} So if you want to look up the type-level `(***)`'s info in this way, you're hosed. If the above scenario seems contrived, and you find yourself thinking "but RyanGlScott, why don't you just use `'(***)` and `''(***)`?", keep in mind that there are times I need to look up //unqualified// names, and in those situations, `mkName` is all I have at my disposal for creating the `Name` to look up. There has to be a better way to go about business here. Perhaps we should introduce another function {{{#!hs reifyAll :: Name -> [Info] }}} That finds all possible `Info`s in all the namespaces the argument `Name` can be found in? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13961 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13961: TH.reify can be ambiguous when giving a name that's in multiple namespaces -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: Component: Template Haskell | Version: 8.0.1 Resolution: invalid | 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: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => closed * resolution: => invalid Comment: Upon further thought, my needs are already addressed with the [http://hackage.haskell.org/package/template-haskell-2.11.1.0/docs /Language-Haskell-TH-Syntax.html#v:lookupValueName lookupValueName] and [http://hackage.haskell.org/package/template-haskell-2.11.1.0/docs /Language-Haskell-TH-Syntax.html#v:lookupTypeName lookupTypeName] functions, which allow me to search in particular namespaces. I now realize that the [http://hackage.haskell.org/package/template- haskell-2.11.1.0/docs/Language-Haskell-TH-Syntax.html#v:reify Haddocks for reify] even point this out - d'oh! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13961#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC