-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Serializable closures for distributed programming. -- -- See README. @package distributed-closure @version 0.3.4.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 GHC.StaticPtr.IsStatic Control.Distributed.Closure.Internal.Closure instance Data.Typeable.Internal.Typeable a => Data.Binary.Class.Binary (Control.Distributed.Closure.Internal.Closure a) -- | Serializable closures for distributed programming. This package builds -- a "remotable closure" abstraction on top of static pointers. -- See this blog post for a longer introduction. 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 -- | It's often useful to create a static dictionary on-the-fly given any -- constraint. Morally, all type class constraints have associated static -- dictionaries, since these are either global values or simple -- combinations thereof. But GHC doesn't yet know how to invent a static -- dictionary on-demand yet given any type class constraint, so we'll -- have to do it manually for the time being. By defining instances of -- this type class manually, or via withStatic if it becomes too -- tedious. class c => Static c closureDict :: Static c => Closure (Dict c) -- | Utility Template Haskell macros. module Control.Distributed.Closure.TH -- | $(cstatic 'foo) is an abbreviation for closure (static -- foo). cstatic :: Name -> ExpQ cstaticDict :: Name -> ExpQ -- | Abbreviation for closure (static Dict). Example usage: -- --
--   foo :: Closure (Dict (Num a)) -> ...
--   
--   foo $cdict ...
--   
cdict :: ExpQ cdictFrom :: Natural -> ExpQ -- | Auto-generates the Static instances corresponding to the given -- class instances. Example: -- --
--   data T a = T a
--   
--   withStatic [d| instance Show a => Show (T a) where ... |]
--   ======>
--   instance Show a => Show (T a) where ...
--   instance (Static (Show a), Typeable a) => Static (Show (T a)) where
--     closureDict = closure (static (Dict -> Dict)) cap closureDict
--   
withStatic :: DecsQ -> DecsQ