runtime reflection for classes

Bulat Ziganshin bulatz at
Thu Feb 9 08:24:03 EST 2006

Hello Johannes,

Thursday, February 09, 2006, 2:43:49 PM, you wrote:

>> again TH can be used and you will be limited only by the volume of
>> information, available for TH code. 

JW> Is information such as "instance C t1 t2 .. " available for such code?

JW> I guess not since this would require information from the compiler
JW> (type checker), but TH splicing runs earlier?

afair, this info is not available, but not because TH runs too early
(info about types structure is available, for example), but just
because it is not still implemented (although there was the requests
about adding this feature).

in meantime, you can use the usual trick: enclose the whole module
text (or at least these "instance" declarations) in the [d|...|]
parentheses and generate all additrional definitions using analysis of
program text instead of analysis of reified typing information.

at least, this way you can implement all what you want without waiting
while GHC team will change something in TH/SYB. and, imho, main
feature of SYB is not generation of RTTI (run-time type information)
but inventing of cool combinators to process data structures
dynamically, without prior knowledge of the exact type structure. that
is a really far beyound of my own abilities

Best regards,
 Bulat                            mailto:bulatz at

More information about the Haskell-prime mailing list