runtime reflection for classes

Bulat Ziganshin bulatz at
Thu Feb 9 06:19:44 EST 2006

Hello Johannes,

Thursday, February 09, 2006, 1:43:38 PM, you wrote:

JW> With Data.Generics, we can get an object's type, constructor and fields.

really, SYB way to metaprogramming is just to encode information about
type in the datastructure. you can do somethiong in this fashion just
by coupling together value and functions that is able to show, map and
otherwise process this value. due to simple changes in the compiler,
functions that translate value into such self-describing structure,
are generated automatically. but they can be written manually or by TH
9it was used before compiler was modified). so it is not exact
compile-time vs dynamic inspection of metainformation, it's just a
general datatype which hoilds all the metainformation about value and
therefore can be inspected at run-time to dynamically decide what to
do with that value

in its current state, information coupled together with value, don't
include that you want, but this can be changed. again, this change
need to either change a compiler so that it can pack his information
when converting "a->Dynamic", or you can write these data manually, or
again TH can be used and you will be limited only by the volume of
information, available for TH code. except for this, extensing SYB
don't require any extensions to the language

Best regards,
 Bulat                            mailto:bulatz at

More information about the Haskell-prime mailing list