[Haskell-cafe] Haskell RPC

S. Alexander Jacobson alex at alexjacobson.com
Thu May 25 17:31:04 EDT 2006

Given that we have no easy way to serialize thunks, the whole RPC 
approach just seems wrong for Haskell.

RPC in general is pretty old school.  REST seems to have worked better 
in practice (e.g. HTTP GET/POST!).

For a general description of REST see

For a summary of the REST vs RPC issue see e.g.

Note that Amazon exposed both sorts of interfaces and found the REST 
style interface much more popular!

That being said, I am actually looking or a good Haskell SOAP client 
lib to talk to paypal so YMMV.


S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com

On Thu, 25 May 2006, Joel Reymont wrote:

> Folks,
> I'm curious about how the following bit of Lisp code would translate to 
> Haskell. This is my implementation of Lisp RPC and it basically sends strings 
> around, printed "readably" and read on the other end by the Lisp reader. If I 
> have a list '(1 2) it prints as "(1 2)" and becomes '(1 2) again when read on 
> the other end.
> I'm wrote a couple of macros to make the job of defining the RPC easier. 
> def-remote-class defines the main (server) class as well as the client 
> (proxy) class.
> def-remote-method creates the server method as well as a proxy method that 
> sends data over and possibly waits for results and returns them (depending on 
> the :async or :sync qualifier). My Lisp RPC code runs on top of UDP, looks 
> good and works well. I have a soft spot for Haskell in my heart, though, so I 
> wonder how I would go about implementing the same architecture in Haskell.
> This is an example from my test harness:
> (define-test remote-basic
>  (def-remote-class remote (server) ())
>  (def-remote-method sum :sync ((self remote) (a fixnum) (b integer))
>                     (declare (ignorable ip port))
>                     (+ a b seqnum))
>  (let* ((port (+ 1000 (random 50000)))
>         (server (make-instance 'remote
>                                :port port))
>         (client (make-instance 'remote-proxy
>                                :host (host-address)
>                                :port port)))
>    (assert-equal '(6) (sum client 1 2 :seqnum 3))
>    (stop server)
>    (stop client)
>    ))
> I think I can send Haskell code over the wire to be read on the other side 
> just like I do with Lisp. The part that baffles me is being able to provide 
> an interface that lets one easily define remote classes and methods.
> I totally hate Template Haskell because I find it incomprehensible and I'm 
> not going to compare it to Lisp macros. Is there a way to do it without TH?
> Also, it seems to me that the only way to deal with variable numbers of 
> differently typed arguments is to use the HList approach which is quite heavy 
> machinery, IMO.
> Any suggestions?
> 	Thanks, Joel
> P.S. The Haskell Cafe has been a bit quiet lately so I do mean to stir it up 
> some. I think this example shows the advantage of dynamically-typed 
> languages.  I'm also genuinely interested in possible Haskell solutions.
> --
> http://wagerlabs.com/
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list