-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Like 'forkIO', but uses remote machines instead of local threads. -- -- This library provides a way to offload a computation to another -- machine. -- -- It uses pluggable Backend's to spawn remote executors. It -- currently only supports AWS Lambda using -- distributed-fork-aws-lambda library. -- -- See README for the rationale behind the library and -- Control.Distributed.Fork module for the usage. @package distributed-fork @version 0.0.1.3 -- | You only need this module if you want to create a new backend for -- distributed-fork. -- -- See localProcessBackend for a minimal example. module Control.Distributed.Fork.Backend -- | Backend is responsible for running your functions in a remote -- environment. -- -- See: -- --
newtype Backend Backend :: (ByteString -> BackendM ByteString) -> Backend -- | 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. [bExecute] :: Backend -> ByteString -> BackendM ByteString -- | BackendM is essentially IO, but also has the ability to report -- the status of the executor. data BackendM a -- | We switch to executor mode only when argv[1] == -- argExecutorMode. argExecutorMode :: String data ExecutorFinalStatus a ExecutorFailed :: Text -> ExecutorFinalStatus a ExecutorSucceeded :: a -> ExecutorFinalStatus a data ExecutorStatus a ExecutorPending :: ExecutorPendingStatus -> ExecutorStatus a ExecutorFinished :: (ExecutorFinalStatus a) -> ExecutorStatus a data ExecutorPendingStatus ExecutorWaiting :: (Maybe Text) -> ExecutorPendingStatus ExecutorSubmitted :: (Maybe Text) -> ExecutorPendingStatus ExecutorStarted :: (Maybe Text) -> ExecutorPendingStatus waiting :: BackendM () waitingDesc :: Text -> BackendM () submitted :: BackendM () submittedDesc :: Text -> BackendM () started :: BackendM () startedDesc :: Text -> BackendM () -- | Lift a computation from the IO monad. liftIO :: MonadIO m => forall a. () => IO a -> m a -- | Returns the absolute pathname of the current executable. -- -- Note that for scripts and interactive sessions, this is the path to -- the interpreter (e.g. ghci.) getExecutablePath :: IO FilePath -- | This module provides a common interface for offloading an IO action to -- remote executors. -- -- It uses StaticPointers language extension and -- distributed-closure library for serializing closures to run -- remotely. This blog post is a good introduction for those. -- -- In short, if you you need a Closure a: -- --
-- {-# LANGUAGE StaticPointers #-}
--
-- import Control.Distributed.Fork
-- import Control.Distributed.Fork.LocalProcessBackend
--
-- main :: IO ()
-- main = do
-- initDistributedFork
-- handle <- fork localProcessBackend (static Dict) (static (return "Hello World!"))
-- await handle >>= putStrLn
--
fork :: Backend -> Closure (Dict (Serializable a)) -> Closure (IO a) -> IO (Handle a)
-- | 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:
--
-- -- main = do -- initDistributedFork -- ... --initDistributedFork :: IO () -- | Backend is responsible for running your functions in a remote -- environment. -- -- See: -- -- data Backend -- | Result of a fork is an Handle where you can await a -- result. data Handle a -- | Blocks until the Handle completes. -- -- Can throw ExecutorFailedException. await :: Handle a -> IO a newtype ExecutorFailedException ExecutorFailedException :: Text -> ExecutorFailedException -- | 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 :: * -> * -- | 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 -- | 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 -- | 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 -> * [Dict] :: Dict a instance GHC.Classes.Eq Control.Distributed.Fork.ExecutorFailedException instance GHC.Show.Show Control.Distributed.Fork.ExecutorFailedException instance GHC.Exception.Exception Control.Distributed.Fork.ExecutorFailedException module Control.Distributed.Fork.LocalProcessBackend -- | A Backend which uses local processes as executors. Useful for -- testing. localProcessBackend :: Backend module Control.Distributed.Fork.Utils -- | Runs given closures concurrently using the Backend with a -- progress bar. -- -- Throws ExecutorFailedException if something fails. mapConcurrentlyWithProgress :: Backend -> Closure (Dict (Serializable a)) -> [Closure (IO a)] -> IO [a]