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

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

Instances

 Source # Methods Source # MethodsstaticMap :: (Typeable * a, Typeable * b) => Closure (a -> b) -> Closure a -> Closure b Source # Source # MethodsstaticExtract :: Typeable * a => Closure a -> a Source # Source # MethodsstaticDuplicate :: Typeable * a => Closure a -> Closure (Closure a) Source #staticExtend :: (Typeable * a, Typeable * b) => Closure (Closure a -> b) -> Closure a -> Closure b Source # Source # MethodsstaticApply :: (Typeable * a, Typeable * b) => Closure (a -> b) -> Closure a -> Closure b Source # Source # MethodsstaticBind :: (Typeable * a, Typeable * b) => Closure a -> Closure (a -> Closure b) -> Closure b Source #staticJoin :: Typeable * a => Closure (Closure a) -> Closure a Source # Typeable * a => Binary (Closure a) Source # Methodsput :: Closure a -> Put #get :: Get (Closure a) #putList :: [Closure a] -> Put #

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 #

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.