[Haskell-cafe] help with dynamic load

Bernie Pope florbitous at gmail.com
Sat Mar 26 02:52:42 CET 2011


On 26 March 2011 05:57, Rob Nikander <rob.nikander at gmail.com> wrote:

> I'm trying to use the 'plugins' package.  Since I already posted to
> stackoverflow I'll just link to that.  I posted a simple program that
> I thought would work, but mostly doesn't.   Any pointers, appreciated.
>
> http://stackoverflow.com/questions/5427777/help-with-haskell-dynamic-plugin-load

Hi Rob,

I don't have a stack overflow account, so I will give a partial answer here.

I'm not sure what the issue is with runhaskell, but you are getting a
segfault with dynload. The comments on dynload in the source of the
plugins package reveal the probable cause:

\begin{comment}
-- A work-around for Dynamics. The keys used to compare two TypeReps are
-- somehow not equal for the same type in hs-plugin's loaded objects.
-- Solution: implement our own dynamics...
--
-- The problem with dynload is that it requires the plugin to export
-- a value that is a Dynamic (in our case a (TypeRep,a) pair). If this
-- is not the case, we core dump. Use pdynload if you don't trust the
-- user to supply you with a Dynamic
\end{comment}

So it seems that, to use dynload, you must export a pair containing a
typerep and a value, rather than just a value. Plugins also provides
pdynload, which is apparently a "super-replacement for dynload",
though I didn't look into it in detail.

Cheers,
Bernie.



More information about the Haskell-Cafe mailing list