Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing a function over network in Haskell

Tags:

haskell

Suppose the following:

I have a type called World representing some simulation state. I also have this type synonym:

type Update = World -> World

Is Haskell capable of serializing the Update type such that it can be passed over the network? Or is there any other means of doing so? Maybe I'm not looking for a serialization of the code's logic so much, as some kind of pointer or identifier that can be read on the other end. Both the sending and receiving process are running the same Haskell program.

like image 968
rlkw1024 Avatar asked Apr 16 '13 19:04

rlkw1024


2 Answers

The distributed-process package is exactly what you described. Since each program already has the same set of functions a pointer to the function is passed from one process to another. There has been mentioned serialization of the function as a potential future goal but is sound like it might take a change to GHC. The github page is a good resource for what backends exist. The github-pages look very nice with some examples, but I did not know about it until a moment ago.

The few Haskell Parallel digests around issue 11 is where I remember learning the most. Definitely take some time to explore github-pages I know I will be.

If I remember correctly there are simple examples in the hackage package or on the github repo exploring work stealing vs work sharing and similar strategies.

like image 148
Davorak Avatar answered Nov 04 '22 23:11

Davorak


I suggest making a DSL data structure. Sadly Haskell does not have lisp's runtime compilation features, but it should be sufficient.

like image 3
Kile Damgaard Asmussen Avatar answered Nov 05 '22 01:11

Kile Damgaard Asmussen