[Haskell-cafe] Looking-up a TyCon of a type exposed from public module but defined in hidden module
石井大海
konn.jinro at gmail.com
Sat Feb 1 11:59:05 UTC 2020
Hi cafe,
I'm currently writing GHC Type-Checker Plugin [ghc-typelits-presburger], which enhances type-inference involving type-level naturals using Presburger arithmetic.
To process constraints properly, I need an access to TyCons of `TrueSym0`,
`FalseSym0`, `GTSym0`, etc. from `singletons` package.
These types are exposed by public modules, e.g. Data.Singletons.Prelude, but
it seems that they are originally defined in private module `Data.Singletons.Prelude.Instances`.
I first tried, to retrieve the `TyCon` for `TrueSym0`, the following:
```
insts <- lookupModule (mkModuleName "Data.Singletons.Prelude.Instances") (fsLit "singletons")
singTrueSym0 <- tcLookupTyCon =<< lookupOrig insts (mkTcOcc "TrueSym0")
```
But this results in the following compile-time error:
```
ghc: panic! (the 'impossible' happened)
(GHC version 8.6.5 for x86_64-apple-darwin):
Unable to resolve module looked up by plugin:
Data.Singletons.Prelude.Instances
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
Then, I tried to lookup `TrueSym0` from exposed module, say Data.Singletons.Prelude:
```
prel <- lookupModule (mkModuleName "Data.Singletons.Prelude") (fsLit "singletons")
singTrueSym0 <- tcLookupTyCon =<< lookupOrig prel (mkTcOcc "TrueSym0")
```
But this resulted in the following error:
```
• Can't find interface-file declaration for type constructor or class singletons-2.5.1:Data.Singletons.Prelude.TrueSym0
Probable cause: bug in .hi-boot file, or inconsistent .hi file
Use -ddump-if-trace to get an idea of which file caused the error
• In the type signature: ...
```
Is there any way, in GHC API, to lookup symbols exported from public module but originally defined in hidden module?
Thanks,
[ghc-typelits-presburger]: https://github.com/konn/ghc-typelits-presburger
-- Hiromi ISHII
konn.jinro at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: Message signed with OpenPGP
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20200201/8dd83c07/attachment.sig>
More information about the Haskell-Cafe
mailing list