Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module provides a common interface for offloading an IO action to remote executors.
Synopsis
- fork :: MonadIO m => Backend -> Closure (Dict (Serializable a)) -> Closure (IO a) -> m (Handle a)
- initDistributedFork :: IO ()
- data Backend
- data Handle a
- await :: (MonadIO m, MonadThrow m) => Handle a -> m a
- pollHandle :: Handle a -> STM (ExecutorStatus a)
- data ExecutorStatus a
- data ExecutorPendingStatus
- data ExecutorFinalStatus a
- newtype ExecutorFailedException = ExecutorFailedException Text
- type Serializable a = (Binary a, Typeable a)
- data Closure a
- cap :: Typeable a => Closure (a -> b) -> Closure a -> Closure b
- cpure :: Closure (Dict (Serializable a)) -> a -> Closure a
- data Dict a where
Documentation
fork :: MonadIO m => Backend -> Closure (Dict (Serializable a)) -> Closure (IO a) -> m (Handle a) Source #
initDistributedFork :: IO () Source #
On distributed-fork, we run the same binary both in your machine (called
"driver") and in the remote environment (called "executor"). In order for the
program to act according to where it is, you should call this function as the
first thing in your main
:
Backend
is responsible for running your functions in a remote environment.
Should run the current binary in the target environment, put the given
string as standard input and return the executables answer on the standard
output.
|
BackendM is essentially IO
, but also has the ability to report the status of the
executor.
Handle
ExecutorStatus
pollHandle :: Handle a -> STM (ExecutorStatus a) Source #
Get the current status of given Handle
.
data ExecutorStatus a Source #
Instances
Functor ExecutorStatus Source # | |
Defined in Control.Distributed.Fork.Internal fmap :: (a -> b) -> ExecutorStatus a -> ExecutorStatus b Source # (<$) :: a -> ExecutorStatus b -> ExecutorStatus a Source # | |
Eq a => Eq (ExecutorStatus a) Source # | |
Defined in Control.Distributed.Fork.Internal (==) :: ExecutorStatus a -> ExecutorStatus a -> Bool Source # (/=) :: ExecutorStatus a -> ExecutorStatus a -> Bool Source # |
data ExecutorPendingStatus Source #
Instances
data ExecutorFinalStatus a Source #
Instances
Exceptions
newtype ExecutorFailedException Source #
Instances
Re-exports
type Serializable a = (Binary a, Typeable a) Source #
Values that can be sent across the network.
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.
Instances
IsStatic Closure | |
Defined in Control.Distributed.Closure.Internal fromStaticPtr :: StaticPtr a -> Closure a Source # | |
StaticApply Closure | |
Defined in Control.Applicative.Static | |
StaticFunctor Closure | |
Typeable a => Binary (Closure a) | |
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.
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.
Values of type
capture a dictionary for a constraint of type Dict
pp
.
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.
Instances
HasDict a (Dict a) | |
a :=> (Read (Dict a)) | |
a :=> (Monoid (Dict a)) | |
a :=> (Enum (Dict a)) | |
a :=> (Bounded (Dict a)) | |
() :=> (Eq (Dict a)) | |
() :=> (Ord (Dict a)) | |
() :=> (Show (Dict a)) | |
() :=> (Semigroup (Dict a)) | |
a => Bounded (Dict a) | |
a => Enum (Dict a) | |
Defined in Data.Constraint succ :: Dict a -> Dict a Source # pred :: Dict a -> Dict a Source # toEnum :: Int -> Dict a Source # fromEnum :: Dict a -> Int Source # enumFrom :: Dict a -> [Dict a] Source # enumFromThen :: Dict a -> Dict a -> [Dict a] Source # enumFromTo :: Dict a -> Dict a -> [Dict a] Source # enumFromThenTo :: Dict a -> Dict a -> Dict a -> [Dict a] Source # | |
Eq (Dict a) | |
(Typeable p, p) => Data (Dict p) | |
Defined in Data.Constraint gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Dict p -> c (Dict p) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Dict p) Source # toConstr :: Dict p -> Constr Source # dataTypeOf :: Dict p -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Dict p)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Dict p)) Source # gmapT :: (forall b. Data b => b -> b) -> Dict p -> Dict p Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Dict p -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Dict p -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Dict p -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Dict p -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Dict p -> m (Dict p) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Dict p -> m (Dict p) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Dict p -> m (Dict p) Source # | |
Ord (Dict a) | |
Defined in Data.Constraint | |
a => Read (Dict a) | |
Show (Dict a) | |
Semigroup (Dict a) | |
a => Monoid (Dict a) | |
NFData (Dict c) | |
Defined in Data.Constraint |