[GHC] #13961: TH.reify can be ambiguous when giving a name that's in multiple namespaces
GHC
ghc-devs at haskell.org
Wed Jul 12 03:32:38 UTC 2017
#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
More information about the ghc-tickets
mailing list