Re: Accessing the "original" names via GHC API

2017-01-25 Thread Ranjit Jhala
@Simon, The route you outline was the one we already use -- but that gives back the full name "Data.Set.Base.Set" (instead of "S.Set" or "Data.Set.Set"), as the module is "Data.Set.Base". @Edward, Yes, I think your suggestion should work! This business of determining which packages/modules are

Re: Accessing the "original" names via GHC API

2017-01-25 Thread Edward Z. Yang
Hi Ranjit, Unfortunately you need more information to do this, since the set of modules which are available for import can vary depending on whether or not packages are hidden or not (not even counting whether or not a module is exposed or not!) The way GHC's pretty printer gives a good name is

RE: Accessing the "original" names via GHC API

2017-01-25 Thread Simon Peyton Jones via Glasgow-haskell-users
that help? S From: Glasgow-haskell-users [mailto:glasgow-haskell-users-boun...@haskell.org] On Behalf Of Ranjit Jhala Sent: 25 January 2017 00:09 To: glasgow-haskell-users@haskell.org Subject: Accessing the "original" names via GHC API Hi, I'm quite vexed trying to do the following.

Re: Accessing the "original" names via GHC API

2017-01-24 Thread Ranjit Jhala
Dear Joachim, You are right -- some more context. Given tc :: TyCon m :: ModName env :: HscEnv I want to get a s :: String such that _in_ the context given by `m` and `env` I can resolve `s` to get back the original `TyCon`, e.g. something like L _ rn <- hscParseIdentifier env

Re: Accessing the "original" names via GHC API

2017-01-24 Thread Joachim Breitner
Hi Ranjit, Am Dienstag, den 24.01.2017, 16:09 -0800 schrieb Ranjit Jhala: > My goal is to write a function > >    tyconString :: TyCon -> String  > > (perhaps with extra parameters) such that given the  > `TyCon` corresponding to `Set`, I get back the "original"  > name `S.Set`, or even

Accessing the "original" names via GHC API

2017-01-24 Thread Ranjit Jhala
Hi, I'm quite vexed trying to do the following. Suppose I have a file: ``` module Foo import qualified Data.Set as S baz :: S.Set Int baz = S.empty ``` My goal is to write a function tyconString :: TyCon -> String (perhaps with extra parameters) such that given the `TyCon` corresponding