Serializable closures for distributed programming.
Go to file
2023-11-27 08:33:08 -03:00
.buildkite Use the new Buildkite setup and build with Nix 2020-02-13 11:41:06 +01:00
examples Allow instance Typeable in withStatic blocks 2018-09-12 23:38:12 +02:00
nix/nixpkgs Use the new Buildkite setup and build with Nix 2020-02-13 11:41:06 +01:00
src fix: compatibility with template-haskell 2.16 2020-06-19 17:07:47 +02:00
tests Turn on UndecidableInstances in test file. 2019-03-20 14:49:36 +01:00
.gitignore Create .gitignore 2017-06-16 12:36:12 -07:00
CHANGELOG.md Update CHANGELOG.md 2023-11-27 08:32:57 -03:00
default.nix Apply more strict flags but only on CI 2020-02-13 11:41:06 +01:00
distributed-closure.cabal Bump version to 0.5.0.0 2023-11-27 08:33:08 -03:00
LICENSE.md Use the new Buildkite setup and build with Nix 2020-02-13 11:41:06 +01:00
README.md Use Buildkite badge 2019-12-29 21:37:39 +01:00
Setup.hs Make cabal check clean. 2015-05-25 20:42:30 +02:00
shell.nix Use the new Buildkite setup and build with Nix 2020-02-13 11:41:06 +01:00

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)

An example of sending static pointers and closures through a communication channel is provided under examples/ClientServer.hs in the source repository.

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