Safe Haskell | None |
---|---|
Language | Haskell2010 |
Utilities to implement effectful server-loops.
Since: 0.24.0
Synopsis
- class Server (a :: Type) (e :: [Type -> Type]) where
- data Init a
- type ServerPdu a :: Type
- type ServerEffects a e :: [Type -> Type]
- serverTitle :: Init a -> ProcessTitle
- runEffects :: Endpoint (ServerPdu a) -> Init a -> Eff (ServerEffects a e) x -> Eff e x
- onEvent :: Endpoint (ServerPdu a) -> Init a -> Event (ServerPdu a) -> Eff (ServerEffects a e) ()
- data Event a where
- OnCall :: forall a r. (Tangible r, TangiblePdu a (Synchronous r)) => ReplyTarget a r -> Pdu a (Synchronous r) -> Event a
- OnCast :: forall a. TangiblePdu a Asynchronous => Pdu a Asynchronous -> Event a
- OnInterrupt :: Interrupt Recoverable -> Event a
- OnDown :: ProcessDown -> Event a
- OnTimeOut :: TimerElapsed -> Event a
- OnMessage :: StrictDynamic -> Event a
- start :: forall a r q. (Server a (Processes q), Typeable a, Typeable (ServerPdu a), FilteredLogging (Processes q), HasProcesses (ServerEffects a (Processes q)) q, HasProcesses r q, HasCallStack) => Init a -> Eff r (Endpoint (ServerPdu a))
- startLink :: forall a r q. (Typeable a, Typeable (ServerPdu a), Server a (Processes q), FilteredLogging (Processes q), HasProcesses (ServerEffects a (Processes q)) q, HasProcesses r q, HasCallStack) => Init a -> Eff r (Endpoint (ServerPdu a))
- protocolServerLoop :: forall q a. (Server a (Processes q), FilteredLogging (Processes q), HasProcesses (ServerEffects a (Processes q)) q, Typeable a, Typeable (ServerPdu a)) => Init a -> Eff (Processes q) ()
Documentation
class Server (a :: Type) (e :: [Type -> Type]) where Source #
A type class for effectful server loops.
This type class serves as interface for other abstractions, for example process supervision
The methods of this class handle Event
s Request
s for Pdu
instance.
Instances can by index types for Pdu
family directly, or indirectly via the ServerPdu
type family.
To builder servers serving multiple protocols, use the generic Pdu
instances, for which Embeds
instances exist, like 2-,3-,4-, or 5-tuple.
Since: 0.24.1
Nothing
The value that defines what is required to initiate a Server
loop.
type ServerPdu a :: Type Source #
The index type of the Event
s that this server processes.
This is the first parameter to the Request
and therefore of
the Pdu
family.
type ServerEffects a e :: [Type -> Type] Source #
Effects of the implementation
Since: 0.24.1
serverTitle :: Init a -> ProcessTitle Source #
Return the ProcessTitle
.
Usually you should rely on the default implementation
serverTitle :: Typeable a => Init a -> ProcessTitle Source #
Return the ProcessTitle
.
Usually you should rely on the default implementation
runEffects :: Endpoint (ServerPdu a) -> Init a -> Eff (ServerEffects a e) x -> Eff e x Source #
Process the effects of the implementation
runEffects :: ServerEffects a e ~ e => Endpoint (ServerPdu a) -> Init a -> Eff (ServerEffects a e) x -> Eff e x Source #
Process the effects of the implementation
onEvent :: Endpoint (ServerPdu a) -> Init a -> Event (ServerPdu a) -> Eff (ServerEffects a e) () Source #
Update the Model
based on the Event
.
onEvent :: (Show (Init a), Member Logs (ServerEffects a e)) => Endpoint (ServerPdu a) -> Init a -> Event (ServerPdu a) -> Eff (ServerEffects a e) () Source #
Update the Model
based on the Event
.
Instances
This event sum-type is used to communicate incoming messages and other events to the
instances of Server
.
Since: 0.24.0
OnCall :: forall a r. (Tangible r, TangiblePdu a (Synchronous r)) => ReplyTarget a r -> Pdu a (Synchronous r) -> Event a | A Since: 0.24.1 |
OnCast :: forall a. TangiblePdu a Asynchronous => Pdu a Asynchronous -> Event a | |
OnInterrupt :: Interrupt Recoverable -> Event a | |
OnDown :: ProcessDown -> Event a | |
OnTimeOut :: TimerElapsed -> Event a | |
OnMessage :: StrictDynamic -> Event a |
start :: forall a r q. (Server a (Processes q), Typeable a, Typeable (ServerPdu a), FilteredLogging (Processes q), HasProcesses (ServerEffects a (Processes q)) q, HasProcesses r q, HasCallStack) => Init a -> Eff r (Endpoint (ServerPdu a)) Source #
Execute the server loop.
Since: 0.24.0
startLink :: forall a r q. (Typeable a, Typeable (ServerPdu a), Server a (Processes q), FilteredLogging (Processes q), HasProcesses (ServerEffects a (Processes q)) q, HasProcesses r q, HasCallStack) => Init a -> Eff r (Endpoint (ServerPdu a)) Source #
Execute the server loop.
Since: 0.24.0
protocolServerLoop :: forall q a. (Server a (Processes q), FilteredLogging (Processes q), HasProcesses (ServerEffects a (Processes q)) q, Typeable a, Typeable (ServerPdu a)) => Init a -> Eff (Processes q) () Source #
Execute the server loop.
Since: 0.24.0