Loading plugin with ghc api

Simon Marlow marlowsd at gmail.com
Mon Mar 23 08:27:41 EDT 2009

John O'Donnell wrote:
> Hi,
> I would like to use the API for ghc, so that a running program can load 
> a module (Foo.o) and use a function defined in that module. From the 
> documentation available, it seems like thatś possible, but I can´t 
> figure out how to do it. There is an example on the wiki, but the 
> explanation just says the code is equivalent to ghc --make. That example 
> does indeed work, but there is no hint as to whether the running program 
> can then access anything defined in the module it has just loaded.
> Is there any available documentation on how to load a plugin, or any 
> working example somewhere?

Hi John,

Once you have your module loaded, you can call

   dynCompileExpr :: GhcMonad m => String -> m Dynamic

to compile an arbitrary expression, yielding a Dynamic value that you can 
cast to the appropriate type.


More information about the Glasgow-haskell-users mailing list