... | ... | @@ -6,9 +6,9 @@ serialisable closures, building on top of [Typeable](typeable) and [StaticPointe |
|
|
See the root page [DistributedHaskell](distributed-haskell).
|
|
|
|
|
|
|
|
|
The [ distributed-process package](https://hackage.haskell.org/package/distributed-process) implements a framework for distributed
|
|
|
The [distributed-process package](https://hackage.haskell.org/package/distributed-process) implements a framework for distributed
|
|
|
programming *à la* Erlang. Support for static closures is implemented in a separate package called
|
|
|
[ distributed-static package](https://hackage.haskell.org/package/distributed-static). We propose to patch this library in the
|
|
|
[distributed-static package](https://hackage.haskell.org/package/distributed-static). We propose to patch this library in the
|
|
|
following way, and rename it to `distributed-closure`. Ultimately, distributed-closure should be the one-stop shop for all distributed frameworks that wish to allow users to program with static closures.
|
|
|
|
|
|
## Proposed design
|
... | ... | @@ -110,7 +110,7 @@ Notice the pay-as-you-go nature of the instances. Only in instances with polymor |
|
|
|
|
|
### Implementation in GHC
|
|
|
|
|
|
TODO See [ old proposal](https://ghc.haskell.org/trac/ghc/wiki/StaticPointers/Old) and [ blog post](https://ghc.haskell.org/trac/ghc/blog/simonpj/StaticPointers) by Simon PJ.
|
|
|
TODO See [old proposal](https://ghc.haskell.org/trac/ghc/wiki/StaticPointers/Old) and [ blog post](https://ghc.haskell.org/trac/ghc/blog/simonpj/StaticPointers) by Simon PJ.
|
|
|
|
|
|
### Implementation of `distributed-closure`
|
|
|
|
... | ... | @@ -193,12 +193,12 @@ closureAp = Ap |
|
|
```
|
|
|
|
|
|
|
|
|
Notice how `Closure` is *nearly* the free applicative functor, though not completely free, because we impose `Serializable a` in `closurePure`. It *is*, however, a [ semigroupoid](https://hackage.haskell.org/package/semigroupoids).
|
|
|
Notice how `Closure` is *nearly* the free applicative functor, though not completely free, because we impose `Serializable a` in `closurePure`. It *is*, however, a [semigroupoid](https://hackage.haskell.org/package/semigroupoids).
|
|
|
|
|
|
|
|
|
Closure serialization is straightforward, but closure deserialization
|
|
|
is tricky. See
|
|
|
[ this blog post section](https://ghc.haskell.org/trac/ghc/blog/simonpj/StaticPointers#Serialisingstaticpointers) from Simon PJ as to why. The issue is that
|
|
|
[this blog post section](https://ghc.haskell.org/trac/ghc/blog/simonpj/StaticPointers#Serialisingstaticpointers) from Simon PJ as to why. The issue is that
|
|
|
when deserializing from a bytestring to target type `Closure b`, one
|
|
|
needs to ensure that the target type matches the type of the closure
|
|
|
before it was serialized, lest *bad things happen*. We need to impose
|
... | ... | @@ -228,7 +228,7 @@ Ap :: Closure (Any -> c) -> Closure Any -> Closure c |
|
|
```
|
|
|
|
|
|
|
|
|
**Note:** `Any` *must* have a `Typeable` instance. This is the case in GHC 7.8, but in GHC \>= 7.9, `Any` is now a type family with no instance, hence cannot be given a `Typeable` instance (see tickets [\#9429](https://gitlab.haskell.org//ghc/ghc/issues/9429)). Deserialization can go something along the following lines (beware, highly idealized code):
|
|
|
**Note:** `Any` *must* have a `Typeable` instance. This is the case in GHC 7.8, but in GHC \>= 7.9, `Any` is now a type family with no instance, hence cannot be given a `Typeable` instance (see tickets [\#9429](https://gitlab.haskell.org/ghc/ghc/issues/9429)). Deserialization can go something along the following lines (beware, highly idealized code):
|
|
|
|
|
|
|
|
|
```wiki
|
... | ... | |