[Haskell-cafe] Enumerating functions at runtime
Brandon Allbery
allbery.b at gmail.com
Sun Mar 24 04:42:45 CET 2013
On Sat, Mar 23, 2013 at 11:26 PM, Luke Evans <luke at eversosoft.com> wrote:
> I'm curious about using Haskell for metaprogramming.
>
> It looks like I can dynamically compile, load and run some Haskell with
> the plugins package. Actually I've briefly tried this and it seems to work
> for some simple cases at least.
> Now I would like to be able to enumerate precompiled public functions in
> modules that I might use as building blocks in such dynamic compilation.
> So far I'm not seeing anything that does this directly.
> Can anyone provide some pointers?
>
I'm not aware of any canned solutions, but one way you could do it is to
enumerate the symbol table of a compiled module and z-decode symbols;
functions get their types z-encoded into their symbol table names. A more
likely useful way is to extract them from the .hi file; there should be
functions in ghc-api and likely in hint to do this, since the compiler must
do so as part of importing a module; or at worst, you can use ghc
-print-iface to decode a .hi file to text and extract the information that
way.
--
brandon s allbery kf8nh sine nomine associates
allbery.b at gmail.com ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20130323/4feaa368/attachment.htm>
More information about the Haskell-Cafe
mailing list