RE: [Template-haskell] How to get list of instances of a given class?
There's currently no way to get the list of instances of a class. It would not be very difficult to add this. Any volunteers? Or I could do it if there is serious demand. How much difference would it make? I've added a note to the Hawiki page about TH, and pointed to it from GHC's wiki. A really desirable thing would be for someone to write Haddock documentation for the Template Haskell API. Would someone be willing to do that? Simon | -----Original Message----- | From: template-haskell-bounces@haskell.org [mailto:template-haskell-bounces@haskell.org] On | Behalf Of Dimitry Golubovsky | Sent: 13 December 2005 14:38 | To: template-haskell@haskell.org | Subject: [Template-haskell] How to get list of instances of a given class? | | Bulat kindly pointed me to the SerTH example. I also have been trying | to browse the GHC documentation trying to find the answer to my | quesitons. | | I see, for example, what can be gotten for a class (provided that the | name of the class is known): | | data Dec | ... | ClassD Cxt String [String] [Dec] -- or ClassD Cxt Name [Name] | [FunDep] [Dec] in | --6.4.x | InstanceD Cxt Type [Dec] | ... | | The documentation (neither for 6.2.2 nor for the latest) says nothing | about what is in [Dec] for a class. Are instances of the class known | at the moment of slplicing contained there? | | I may be asking too common questions. I just need to see whether my | task is accomplishable via TH. If it is not, then I'll do this via | some plugins to HSFFIG, but the latter is not much desirable. | | Please advise. | | Thanks. | | -- | Dimitry Golubovsky | | Anywhere on the Web
Simon,
Thanks for your reply. This saves me a lot of time as I would not
spend it just to discover this was impossible anyway.
Is it possible to publish a list of what is possible to
access/introspect, and what is not possible? In 6.2.2? In 6.4.1?
For instance, on Dec 12, you explained how module imports may be
accessed, so it is already possible [1], at least in 6.4.1
On 12/16/05, Simon Peyton-Jones
There's currently no way to get the list of instances of a class. It would not be very difficult to add this. Any volunteers? Or I could
do it if there is serious demand. How much difference would it make?
As for myself, I may get around by writing some sort of plugins to HSFFIG because all the information about C structures it processes is available. Anyway, even if you or somebody else implement this now, it will most likely be available in 6.6 only, won't it? Just for the future: from the original Template Haskell paper [2], I got the impression that the ultimate goal was to be able to access the whole tree of objects internally known to the compiler at the moment when the TH constructs are involved, wasn't it? However I understand that the priority is low. Once I tried to implement (with some success) runtime introspection for Hugs, but nobody seemed to show any interest... ------------- [1] http://www.haskell.org//pipermail/template-haskell/2005-December/000501.html [2] http://www.haskell.org/th/papers/meta-haskell.ps -- Dimitry Golubovsky Anywhere on the Web
participants (2)
-
Dimitry Golubovsky -
Simon Peyton-Jones