-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Serializable closures for distributed programming. -- -- See README. @package distributed-closure @version 0.2.0.0 -- | 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. module Control.Distributed.Closure.Internal -- | Values that can be sent across the network. type Serializable a = (Binary a, Typeable a) -- | 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. data Closure a StaticPtr :: !(StaticPtr a) -> Closure a Encoded :: !ByteString -> Closure ByteString Ap :: !(Closure (a -> b)) -> !(Closure a) -> Closure b Closure :: a -> !(Closure a) -> Closure a -- | Lift a Static pointer to a closure with an empty environment. closure :: StaticPtr a -> Closure a -- | 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. unclosure :: Closure a -> a -- | A closure can be created from any serializable value. cpure -- corresponds to Control.Applicative's pure, but -- restricted to lifting serializable values only. cpure :: Closure (Dict (Serializable a)) -> a -> Closure a -- | Closure application. Note that Closure is not a functor, let -- alone an applicative functor, even if it too has a meaningful notion -- of application. cap :: Typeable a => Closure (a -> b) -> Closure a -> Closure b -- | 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. cmap :: Typeable a => StaticPtr (a -> b) -> Closure a -> Closure b instance Data.Typeable.Internal.Typeable a => Data.Binary.Class.Binary (Control.Distributed.Closure.Internal.Closure a) -- | Utility Template Haskell macros. module Control.Distributed.Closure.TH -- | $(cstatic 'foo) is an abbreviation for closure (static -- foo). cstatic :: Name -> ExpQ -- | Abbreviation for closure (static Dict). Example usage: -- --
-- foo :: Closure (Dict (Num a)) -> ... -- -- foo $cdict ... --cdict :: ExpQ -- | Create a static dictionary from the given dictionaries. Example usage: -- --
-- $cdictFrom 2 Dict Dict :: Closure (Static (Dict (Eq a, Show a))) --cdictFrom :: Natural -> ExpQ -- | Serializable closures for distributed programming. module Control.Distributed.Closure -- | Values that can be sent across the network. type Serializable a = (Binary a, Typeable a) -- | 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. data Closure a -- | Lift a Static pointer to a closure with an empty environment. closure :: StaticPtr a -> Closure a -- | 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. unclosure :: Closure a -> a -- | A closure can be created from any serializable value. cpure -- corresponds to Control.Applicative's pure, but -- restricted to lifting serializable values only. cpure :: Closure (Dict (Serializable a)) -> a -> Closure a -- | Closure application. Note that Closure is not a functor, let -- alone an applicative functor, even if it too has a meaningful notion -- of application. cap :: Typeable a => Closure (a -> b) -> Closure a -> Closure b -- | 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. cmap :: Typeable a => StaticPtr (a -> b) -> Closure a -> Closure b -- | Values of type Dict p capture a dictionary for a -- constraint of type p. -- -- e.g. -- --
-- Dict :: Dict (Eq Int) ---- -- captures a dictionary that proves we have an: -- --
-- instance Eq 'Int ---- -- Pattern matching on the Dict constructor will bring this -- instance into scope. data Dict (a :: Constraint) :: Constraint -> * Dict :: Dict a