mirror of
https://github.com/tweag/distributed-closure.git
synced 2024-11-25 08:19:05 +03:00
Serializable closures for distributed programming.
1723990fb7
As requested in #13. |
||
---|---|---|
.circleci | ||
examples | ||
src | ||
tests | ||
.gitignore | ||
.travis.yml | ||
CHANGELOG.md | ||
distributed-closure.cabal | ||
LICENSE | ||
README.md | ||
Setup.hs | ||
stack.yaml |
distributed-closure
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.