Accessing the "original" names via GHC API
Simon Peyton Jones
simonpj at microsoft.com
Wed Jan 25 08:46:07 UTC 2017
The TyCon has a Name (use tyConName to get it).
The Name has a Module and an OccName (use nameModule and nameOccName to get them)
The OccName has a string (occNameString)
The Module has a ModuleName and a Package.
All of these will give the “original-name” info, ignoring what’s in scope.
Does that help?
S
From: Glasgow-haskell-users [mailto:glasgow-haskell-users-bounces at haskell.org] On Behalf Of Ranjit Jhala
Sent: 25 January 2017 00:09
To: glasgow-haskell-users at haskell.org
Subject: Accessing the "original" names via GHC API
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 to `Set`, I get back the "original"
name `S.Set`, or even `Data.Set.Set`.
Everything I've tried, which is fiddling with different variants of `PprStyle`, end up giving me `Data.Set.Base.Set`
Does anyone have a suggestion for how to proceed?
Thanks!
- Ranjit.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/glasgow-haskell-users/attachments/20170125/9c019bb0/attachment-0001.html>
More information about the Glasgow-haskell-users
mailing list