[Haskell-cafe] Serialization of (a -> b) and IO a
Tillmann Rendel
rendel at Mathematik.Uni-Marburg.de
Sat Nov 13 05:27:17 EST 2010
Andrew Coppin wrote:
> [...] if you could send a block of code from one PC to another to
> execute it remotely.
Eden can do this.
http://www.mathematik.uni-marburg.de/~eden/
Eden is a distributed Haskell: You run multiple copies of the same
binary on different machines, and you have the (#) operator to apply
functions *on a remote machine*. So, for example,
process (map f) # xs
will serialize (map f) and send it over to some other machine. At that
other machine, (map f) is deserialized and evaluated. In addition, two
channels between the machines are opened: One for streaming the xs to
that remote machine where the map is executed, and one for streaming the
results back.
The process and (#) operators have the following, rather harmless
looking types:
process :: (a -> b) -> Process a b
(#) :: Process a b -> (a -> b)
So no IO around, even if there is serialization and network
communication going on. If you feel uncomfortable about that, you can
use instantiate instead:
instantiate :: Process a b -> a -> IO b
And indeed, (#) is implemented in terms of instantiate and that
unspeakable source of all false transparency:
p # x = unsafePerformIO (instantiate p x)
Tillmann
More information about the Haskell-Cafe
mailing list