[Haskell-cafe] Retrieving information about type families

Alejandro Serrano Mena trupill at gmail.com
Sat Jul 26 08:57:37 UTC 2014

I'm still struggling with getting the right information. My aim is to know
the kind of a specific variable in a type instance defintion. For example,
if I get:

type family F (x :: Bool)
type instance F y = ()

where ^ marks the point from where I want the information, I want to get "y
has kind Bool".

The approach I'm taking is obtaining the LHsType Name from the specific
position in the RenamedSource of the file. Then, I'm trying to convert
that LHsType
Name to a Type using functions in HscTypes, but I always get complaints
about not existing variables.

In the past, I implemented something similar for normal functions. However,
in that case I could get the information directly from TypecheckedSource,
by querying for a pattern variable with the right location. However, in the
TypecheckedSource there's no information about type families at all :( My
other possibility seems to use the ModuleInfo, but in those places there's
no information of location :(

Is there any way to achieve what I'm trying to do (get the kind of a
specific type variable in the LHS of a type family instance, where the
variable is given by its position in the source code)?

Thanks in advance.

2014-07-25 18:12 GMT+02:00 Alejandro Serrano Mena <trupill at gmail.com>:

> Thanks for the help! At the end I'm trying to get the information from a
> RenamedSource (so I can still get source locations) and then get type
> information using TcHsType. I haven't succedeed yet, but I think I'm on the
> way!
> 2014-07-23 23:38 GMT+02:00 Richard Eisenberg <eir at cis.upenn.edu>:
> Does FamInstEnv.lookupFamInstEnv work for you? You will also probably want
>> FamInst.tcGetFamInstEnvs.
>> Richard
>> On Jul 23, 2014, at 2:48 PM, Alejandro Serrano Mena <trupill at gmail.com>
>> wrote:
>> > Dear Café,
>> > My quest for obtaining information about type families continues.
>> > Now I have a simple question: how should I access the information about
>> "type instance"s via the GHC API? My aim is to do so after type checking,
>> that is, to get that information from a TypecheckedModule. However, I
>> haven't yet been able to touch the right buttons to make it work ;(
>> >
>> > Thanks in advance,
>> > Alejandro
>> > _______________________________________________
>> > Haskell-Cafe mailing list
>> > Haskell-Cafe at haskell.org
>> > http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140726/4c9d243e/attachment.html>

More information about the Haskell-Cafe mailing list