
This is something we've had to do in LiquidHaskell. You might look at the function `stringLookupEnv`: https://github.com/ucsd-progsys/liquidhaskell/blob/master/Language/Haskell/L... the key bits are: *hscParseIdentifier*http://www.haskell.org/ghc/docs/latest/html/libraries/ghc/HscMain.html#v:hsc... :: HscEnv -> String -> IO (Located RdrName)http://www.haskell.org/ghc/docs/latest/html/libraries/ghc/HscMain.html#v:hsc... *tcRnLookupRdrName*http://www.haskell.org/ghc/docs/latest/html/libraries/ghc/TcRnDriver.html#v:... :: HscEnv -> RdrName -> IO (Messages, Maybe [Name])http://www.haskell.org/ghc/docs/latest/html/libraries/ghc/TcRnDriver.html#v:... Note that both of these require that you have an `HscEnv` in hand. Also, the hoogle query: "String -> m Name +ghc" brought up: parseNamehttp://www.haskell.org/ghc/docs/latest/html/libraries/ghc/InteractiveEval.ht... :: GhcMonad m => String -> m [Name]http://www.haskell.org/ghc/docs/latest/html/libraries/ghc/InteractiveEval.ht... which seems like it may be helpful if you don't want to manually pass around HscEnvs... Hope this helps! On Sat, Oct 19, 2013 at 10:19 AM, Daniel Trstenjak < daniel.trstenjak@gmail.com> wrote:
Hi Dan,
Correct me if I am wrong, but you are not supposed to construct 'Name's yourself. The point is that they are unique and hiding the constructors is a step towards preserving the invariants.
Ok, I almost expected something like this.
Here's how I would do something like 'map nameOccName . modInfoExports' and then search for an OccName (which you can construct using mkOccName).
I already tried it this way, but if you're doing this for a lot of modules, than quite a lot of time is just spend creating the list for the returned symbols, which is in my case than immediately discarded after the search.
Greetings, Daniel
_______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users