[Haskell] Dynamic Loading?

Donald Bruce Stewart dons at cse.unsw.edu.au
Sun Mar 20 19:42:31 EST 2005

> Is it possible to do dynamic loading in Haskell?
> Let us say you want to have plug-in loadable widgets. You create a 
> widget API, which is in fact a data-type W (which you make an instance 
> of Typeable). You then write an application that loads widgets, using 
> something like this:
>   loadDynamic :: FilePath -> IO Dynamic
> Someone else could then use your widget API to write code that provides 
> a value of type W (or a Dynamic), and compile and link it as a widget 
> that can then be loaded.
> Is this possible?

You want hs-plugins :)

It provides load functions of various flavours, including one similar to
the above:
   dynload :: Typeable a
        => FilePath
        -> [FilePath]
        -> [PackageConf]
        -> Symbol
        -> IO (LoadStatus a)
(The type is a little more complex due to the need to interact with the module
and package system). 

dynload() unwraps and checks the Dynamic for you. If you want to do this
manually, a straight load() will work.



More information about the Haskell mailing list