-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | a remote procedure call framework -- -- A library and framework for making remote procedure calls in haskell -- easy and typesafe. -- -- See http://github.com/mmirman/rpc-framework for more -- information. @package rpc-framework @version 0.2.0.0 -- | A server that allows for the declaration of services and for the -- calling of services. module Network.Remote.RPC.Internal.MultiServer data ServiceID LocNumber :: Integer -> ServiceID LocName :: String -> ServiceID type Handlers m = Map ServiceID (Handle -> AIO m ()) type State m = MVar (Handlers m, Integer) newtype AIO m a AIO :: (ReaderT (State m) m a) -> AIO m a send :: (Show a, MonadIO m) => Handle -> a -> m () recv :: (Read a, MonadIO m) => Handle -> m a startServer :: (Forkable m, Monad m, MonadIO m) => Integer -> AIO m a -> m a safeFind :: (Ord k, Show k) => Map k a -> k -> a getHandlers :: Monad m => AIO m (State m) addService :: (Monad m, MonadIO m) => (Handle -> AIO m ()) -> AIO m ServiceID addServiceByName :: (Monad m, MonadIO m) => String -> (Handle -> AIO m ()) -> AIO m ServiceID connectToService :: MonadIO m => String -> Integer -> ServiceID -> m Handle -- | Servable is a declaration that the given monad can be made into -- a servlet. class (Functor m, Monad m, MonadIO m, Forkable m) => Servable m instance [incoherent] Forkable m => Forkable (AIO m) instance [incoherent] MonadIO m => MonadIO (AIO m) instance [incoherent] Functor m => Functor (AIO m) instance [incoherent] Monad m => Monad (AIO m) instance [incoherent] Show ServiceID instance [incoherent] Read ServiceID instance [incoherent] Ord ServiceID instance [incoherent] Eq ServiceID instance [incoherent] Servable m => Servable (AIO m) instance [incoherent] Servable IO instance [incoherent] Monad m => MonadReader (State m) (AIO m) instance [incoherent] MonadTrans AIO -- | The functions for using a function as a service and calling a remote -- process module Network.Remote.RPC.Internal.Runtime -- | WIO w m a is a newtype over a server transformer that -- adds the phantom host argument w data WIO w m a -- | onHost declares that the code is running on the given host. it -- is usefull when a type inference is wanted, but the action also needs -- to be made into a service and used as a remote procedure onHost :: (Servable m, Host w) => w -> WIO w m () realRemoteCall :: RPC a a' m w => a -> String -> a' makeService :: Service a m w => a -> String -> WIO w m () -- | Host World declares that the world is a host. It -- should only have one constructor, and the location and port should be -- invariant of the given constructor. Specifically, getLocation -- and getPort should work even if bottom is supplied. class Host a getLocation :: Host a => a -> String getPort :: Host a => a -> Integer getValue :: Host a => a class Servable m => Sendable m a a' | a' -> a, a m -> a', a a' -> m -- | Servable is a declaration that the given monad can be made into -- a servlet. class (Functor m, Monad m, MonadIO m, Forkable m) => Servable m data Ref a a' -- | Lift a computation from the IO monad. liftIO :: MonadIO m => forall a. IO a -> m a -- | runServer runs a name server and doesn't return runServer :: (Servable m, Host w) => WIO w m () -> m () -- | runServerBG runs a name server on a background thread and does -- return runServerBG :: Host w => WIO w IO () -> IO ThreadId instance [incoherent] Read (Ref a a') instance [incoherent] Show (Ref a a') instance [incoherent] Forkable m => Forkable (WIO w m) instance [incoherent] MonadIO m => MonadIO (WIO w m) instance [incoherent] Functor m => Functor (WIO w m) instance [incoherent] Monad m => Monad (WIO w m) instance [incoherent] (Sendable m a' a, Service b m w) => Service (a -> b) m w instance [incoherent] (Host w, Servable m, Sendable m a a') => Service (WIO w m a) m w instance [incoherent] (Sendable m a' a, RPC b b' m w') => RPC (a -> b) (a' -> b') m w' instance [incoherent] (Sendable m' a a', Host w, Host w', Servable m, Servable m') => RPC (WIO w m a) (WIO w' m' a') m' w' instance [incoherent] (Sendable m a' a, Sendable m b b') => Sendable m (a -> b) (a' -> WIO w m b') instance [incoherent] (Read a, Show a', a ~ a', Servable m) => Sendable m a a' instance [incoherent] MonadTrans (WIO w) instance [incoherent] Servable m => Servable (WIO w m) module Network.Remote.RPC.Internal.Templates -- | $(rpcCall 'serviceNm) simply splices in -- realRemoteCall (undefined :: typeofcall) "serviceNm" -- which is typed in a manner similar to typeofcall. rpcCall :: Name -> Q Exp -- | $(makeHost "HostName" "hostLocation" hostPortNumber) -- makes a newtype HostName and declares an instance -- Host HostName. makeHost :: String -> String -> Integer -> Q [Dec] -- | $(makeServices ['service1 ,..., 'serviceN]) makes all -- given services listen for incoming requests. makeServices :: [Name] -> Q Exp -- | $(autoService 'World) finds all services declared in -- the module that definitely run on the given world, and makes them -- listen for incoming requests. autoService :: Name -> Q Exp instance [incoherent] MonadIO Q -- | Declaration of the frontend for RPC. module Network.Remote.RPC -- | Host World declares that the world is a host. It -- should only have one constructor, and the location and port should be -- invariant of the given constructor. Specifically, getLocation -- and getPort should work even if bottom is supplied. class Host a getLocation :: Host a => a -> String getPort :: Host a => a -> Integer getValue :: Host a => a -- | WIO w m a is a newtype over a server transformer that -- adds the phantom host argument w data WIO w m a -- | Servable is a declaration that the given monad can be made into -- a servlet. class (Functor m, Monad m, MonadIO m, Forkable m) => Servable m -- | Lift a computation from the IO monad. liftIO :: MonadIO m => forall a. IO a -> m a -- | runServer runs a name server and doesn't return runServer :: (Servable m, Host w) => WIO w m () -> m () -- | runServerBG runs a name server on a background thread and does -- return runServerBG :: Host w => WIO w IO () -> IO ThreadId -- | onHost declares that the code is running on the given host. it -- is usefull when a type inference is wanted, but the action also needs -- to be made into a service and used as a remote procedure onHost :: (Servable m, Host w) => w -> WIO w m () -- | $(autoService 'World) finds all services declared in -- the module that definitely run on the given world, and makes them -- listen for incoming requests. autoService :: Name -> Q Exp -- | $(makeHost "HostName" "hostLocation" hostPortNumber) -- makes a newtype HostName and declares an instance -- Host HostName. makeHost :: String -> String -> Integer -> Q [Dec] -- | $(makeServices ['service1 ,..., 'serviceN]) makes all -- given services listen for incoming requests. makeServices :: [Name] -> Q Exp -- | $(rpcCall 'serviceNm) simply splices in -- realRemoteCall (undefined :: typeofcall) "serviceNm" -- which is typed in a manner similar to typeofcall. rpcCall :: Name -> Q Exp class Monad m => Forkable m forkIO :: Forkable m => m a -> m ThreadId -- | The class of monad transformers. Instances should satisfy the -- following laws, which state that lift is a transformer of -- monads: -- --
class MonadTrans (t :: (* -> *) -> * -> *) lift :: (MonadTrans t, Monad m) => m a -> t m a