distributed-closure

Serializable closures for distributed programming.

https://github.com/tweag/distributed-closure

Version on this page:0.3.3.0
LTS Haskell 22.40:0.5.0.0
Stackage Nightly 2024-11-05:0.5.0.0
Latest on Hackage:0.5.0.0

See all snapshots distributed-closure appears in

BSD-3-Clause licensed by Mathieu Boespflug
Maintained by [email protected]
This version can be pinned in stack with:distributed-closure-0.3.3.0@sha256:7ecd31f143cb38e0cee207170bee3dbcb00c46db11fa84b52ee46e387f4ca8cc,1482

Module documentation for 0.3.3.0

distributed-closure

Build Status

Leverage the -XStaticPointers extension from GHC 7.10 onwards for distributed programming using lightweight serializable closures. This package implements a serializable closure abstraction on top of static pointers. Serializable closures can be shipped around a computer cluster. This is useful for implementing intuitive and modular distributed applications. See this blog post for a hands on introduction and this paper for the original motivation.

Example

In GHC 8 and above, remoting a computation on another node using this library goes along the lines of

data NodeId

-- Assume we're given a spaw primitive.
spawn :: NodeId -> Closure (IO ()) -> IO ()

-- A computation to remote on another node.
hello :: String -> IO ()
hello name = putStrLn ("Hello, " ++ name)

main = do
  name <- getLine
  spawn "someAddress" (static hello `cap` name)

distributed-closure does not implement sending/receiving/spawning closures - that’s left for higher-level frameworks. Only closure creation, composition and (de)serialization.