distributed-closure

Serializable closures for distributed programming.

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

LTS Haskell 23.27:0.5.0.0
Stackage Nightly 2025-07-12:0.5.0.0
Latest on Hackage:0.5.0.0

See all snapshotsdistributed-closure appears in

BSD-3-Clause licensedbyMathieu Boespflug
Maintained by[email protected]
This version can be pinned in stack with:distributed-closure-0.5.0.0@sha256:beeae8c7905518d7d16a30d74453d50e8223c484df5e7fb65edf9707d8d32f1e,2259

Module documentation for 0.5.0.0

Used by 1 package inlts-23.17(full list with versions):

distributed-closure

Build status

Leverage the-XStaticPointersextensionfrom GHC 7.10 onwards for distributed programming using lightweightserializable closures. This package implements aserializableclosure abstraction on top of static pointers. Serializable closurescan be shipped around a computer cluster. This is useful forimplementing intuitive and modular distributed applications. Seethis blog post for a hands on introductionandthis paper for the original motivation.

Example

In GHC 8 and above, remoting a computation on another node using thislibrary 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)

An example of sending static pointers and closuresthrough a communication channel is provided underexamples/ClientServer.hsin the source repository.

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