[Haskell-cafe] Dynamically find out instances
ofclasses (pluginsystem for haskell)
claus.reinke at talk21.com
Thu Nov 22 19:38:15 EST 2007
> In [gasp!] Java, you can just stick compiled files into a folder, and
> write your main program such that ts scans this folder, loads anything
> it finds, and executes specific code within it. In other words, an
> instant plugin system. I imagine this is what the original poster is after.
dynamic class loaders used to be a favourite question
mark in java type safety investigations.
the wonderful thing is that it has long been known how
to integrate orthogonal persistence (anything can be made
to persist for as long as needed, including features like
storing/retrieving functions into/from long-term storage)
in languages with first-class procedures/functions, as well
as how to integrate dynamic type checks for dynamic
loading into otherwise static type system.
even how to integrate that old research on persistence and
type Dynamic into a type system as complex as haskell's
has been investigated, and i believe that current clean does
support both Dynamic and orthogonal persistence (there
called first-class i/o, because it removes haskell's restriction
of i/o to chars and bytes).
there have been various projects trying to integrate full
Dynamics or better persistence into haskell, but none have
survived, as far as i know. the most recent one might be
glasgow distributed haskell (if you can distribute everything
between haskell processes on different machines, you can
run one process as a persistence server) - i don't know
what state that is in?
there are various clever tricks to get much of Dynamic
without special language support, and several implementation
hacks to support at least dynamic loading of haskell code
(see previous references in this thread). but while i mean
hack in the best sense here, the latter are is still unsafe
(lacking proper foundations in an extended type system,
they circumvent the type system to achieve their aims;
even ghci does that behind the scenes). not being fully
integrated into language and implementations, these hacks
are also notoriously brittle, not working on all platforms,
or breaking with each compiler upgrade, etc.
to cut a long, sad story short: dynamic loading is possible,
but not well supported. if you do depend on the existing
workarounds, expect to go through a lot of trouble,
especially if you expect to maintain your code over more
than one compiler version/platform. it doesn't help to see
all those wonderful papers that remind us of what is
possible in demonstrator projects, when those things
no longer even build a year later, or on your platform..
anyone willing to have yet another go at this, properly,
without temporary workarounds?-) the problem is that
all the academic credit has been taken by earlier projects,
so what is left is a lot of hard work and fiddly details,
and by the time you've finished "porting clean's Dynamics
and first-class i/o to haskell", your favourite haskell
implementations will have moved on and left your
patches behind. just like glasgow parallel and
distributed haskell always seem to lag behind ghc by
about a full version..
perhaps, if the haskell-to-clean translators ever gather
enough momentum, there'd be at least one haskell
implementation supporting these things?
please, someone tell me that i'm too pessimistic,
and that haskell, the language, will have orthogonal
persistence and full Dynamic in the near future!-)
More information about the Haskell-Cafe