Serializable closures for distributed programming.
Go to file
Mathieu Boespflug 5776daefae
Merge pull request #18 from tweag/ghc84
GHC 8.4 compatibility
2018-09-13 10:17:30 +03:00
.circleci Add stack setup step. 2017-06-19 20:19:09 +02:00
examples Allow instance Typeable in withStatic blocks 2018-09-12 23:38:12 +02:00
src Allow instance Typeable in withStatic blocks 2018-09-12 23:38:12 +02:00
tests Import Test.QuickCheck qualified to avoid name clashes. 2018-09-12 23:38:12 +02:00
.gitignore Create .gitignore 2017-06-16 12:36:12 -07:00
.travis.yml Turn on --pedantic. 2017-03-20 19:47:22 +01:00
CHANGELOG.md Bump version to 0.4.0 and update changelog. 2018-02-06 09:20:49 -03:00
distributed-closure.cabal Add an example of sending functions 2018-02-07 10:40:32 +01:00
LICENSE Initial commit. 2015-05-25 13:40:58 +02:00
README.md Add link from README to example 2018-02-07 11:55:15 +01:00
Setup.hs Make cabal check clean. 2015-05-25 20:42:30 +02:00
stack.yaml Switch to LTS 12. 2018-09-12 23:38:12 +02: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.