On Fri, May 26, 2006 at 09:20:25AM +0100, Joel Reymont wrote:
> On May 25, 2006, at 8:34 PM, Robert Dockins wrote:
> >If you want to deliver source code to be executed elsewhere, you  
> >can use hs-plugins or the GHC API (in GHC HEAD branch).
> 
> hs-plugins is too heavy since it runs ghc. I don't need to deliver  
> any type of source code, just a function call and its arguments.

Is there a discrete set of functions you want to be able to call, then? If
so, why not just define a data type:

data MyRPC = LengthIntList [Int] | HeadList [Int] | ...
     deriving ( Show, Read )

Then you just implement a

runfunction (LengthIntList xs) = length xs
runfunction (HeadList (x:_) = x
...

No trickiness required, all you need is one datatype enumerating the
functions you want to be able to call, and a dispatch function.  At the
cost (over lisp) of having to write these enumerations, you gain the safety
of knowing that only that list of functions can be called, and that they
all have the appropriate return type (or maybe they'll all return IO (), I
don't know).
-- 
David Roundy
http://www.darcs.net
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to