Re: [Haskell-cafe] Enumerating functions at runtime
More details about interface files can be found at http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/IfaceFiles -- in particular the 'ghc --show-iface' part should be of great interest to you. On Sun, Mar 24, 2013 at 12:22 PM, Don Stewart don...@gmail.com wrote: All the info is in the .hi files On Sunday, 24 March 2013, Brent Yorgey wrote: On Sat, Mar 23, 2013 at 08:26:52PM -0700, Luke Evans 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? If it's just not possible to introspect on compiled modules, then I suppose I could use external metadata of my own, or even perhaps haddock info if it exists, to attempt to generate this info. Clearly though, that's nowhere near as good as extracting the info from something the compiler built directly. I have no idea how it works, but I'm pretty sure yi does this --- e.g. if you hit M-x (when in emacs emulation mode) and then tab-complete, you see a list of all the available functions. Maybe you want to take a look at the yi source code and see how they do it. -Brent ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Alp Mestanogullari ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Enumerating functions at runtime
On Sat, Mar 23, 2013 at 08:26:52PM -0700, Luke Evans 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? If it's just not possible to introspect on compiled modules, then I suppose I could use external metadata of my own, or even perhaps haddock info if it exists, to attempt to generate this info. Clearly though, that's nowhere near as good as extracting the info from something the compiler built directly. I have no idea how it works, but I'm pretty sure yi does this --- e.g. if you hit M-x (when in emacs emulation mode) and then tab-complete, you see a list of all the available functions. Maybe you want to take a look at the yi source code and see how they do it. -Brent ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Enumerating functions at runtime
All the info is in the .hi files On Sunday, 24 March 2013, Brent Yorgey wrote: On Sat, Mar 23, 2013 at 08:26:52PM -0700, Luke Evans 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? If it's just not possible to introspect on compiled modules, then I suppose I could use external metadata of my own, or even perhaps haddock info if it exists, to attempt to generate this info. Clearly though, that's nowhere near as good as extracting the info from something the compiler built directly. I have no idea how it works, but I'm pretty sure yi does this --- e.g. if you hit M-x (when in emacs emulation mode) and then tab-complete, you see a list of all the available functions. Maybe you want to take a look at the yi source code and see how they do it. -Brent ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org javascript:; http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Enumerating functions at runtime
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? If it's just not possible to introspect on compiled modules, then I suppose I could use external metadata of my own, or even perhaps haddock info if it exists, to attempt to generate this info. Clearly though, that's nowhere near as good as extracting the info from something the compiler built directly. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Enumerating functions at runtime
On Sat, Mar 23, 2013 at 11:26 PM, Luke Evans l...@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 allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe