distributed-closure-0.4.0: Serializable closures for distributed programming.

Safe HaskellNone
LanguageHaskell2010

Control.Distributed.Closure.Internal

Description

Private internals. You should not use this module unless you are determined to monkey with the internals. This module comes with no API stability guarantees whatsoever. Use at your own risks.

Synopsis

Documentation

type Serializable a = (Binary a, Typeable a) Source #

Values that can be sent across the network.

data Closure a where Source #

Type of serializable closures. Abstractly speaking, a closure is a code reference paired together with an environment. A serializable closure includes a shareable code reference (i.e. a StaticPtr). Closures can be serialized only if all expressions captured in the environment are serializable.

Constructors

StaticPtr :: !(StaticPtr a) -> Closure a 
Encoded :: !ByteString -> Closure ByteString 
Ap :: !(Closure (a -> b)) -> !(Closure a) -> Closure b 
Duplicate :: Closure a -> Closure (Closure a) 
Closure :: a -> !(Closure a) -> Closure a 

closure :: StaticPtr a -> Closure a Source #

Lift a Static pointer to a closure with an empty environment.

unclosure :: Closure a -> a Source #

Resolve a Closure to the value that it represents. Calling unclosure multiple times on the same closure is efficient: for most argument values the result is memoized.

cpure :: Closure (Dict (Serializable a)) -> a -> Closure a Source #

A closure can be created from any serializable value. cpure corresponds to Control.Applicative's pure, but restricted to lifting serializable values only.

cap :: Typeable a => Closure (a -> b) -> Closure a -> Closure b Source #

Closure application. Note that Closure is not a functor, let alone an applicative functor, even if it too has a meaningful notion of application.

capDup :: Typeable a => Closure (Closure a -> b) -> Closure a -> Closure b Source #

Nested closure application.

cmap :: Typeable a => StaticPtr (a -> b) -> Closure a -> Closure b Source #

Deprecated: Use staticMap instead.

Closure is not a Functor, in that we cannot map arbitrary functions over it. That is, we cannot define fmap. However, we can map a static pointer to a function over a Closure.

cduplicate :: Closure a -> Closure (Closure a) Source #

Turn a closure into a closure of a closure.