extensible-effects-concurrent-0.32.0: Message passing concurrency as extensible-effect

Safe HaskellNone
LanguageHaskell2010

Control.Eff.Concurrent.Protocol.CallbackServer

Description

Build a Control.Eff.Concurrent.EffectfulServer from callbacks.

This module contains in instance of Server that delegates to callback functions.

Since: 0.27.0

Synopsis

Documentation

start :: forall (tag :: Type) eLoop q e. (HasCallStack, TangibleCallbacks tag eLoop q, Server (Server tag eLoop q) (Processes q), FilteredLogging (Processes q), HasProcesses e q) => CallbacksEff tag eLoop q -> Eff e (Endpoint tag) Source #

Execute the server loop, that dispatches incoming events to either a set of Callbacks or CallbacksEff.

Since: 0.29.1

startLink :: forall (tag :: Type) eLoop q e. (HasCallStack, TangibleCallbacks tag eLoop q, Server (Server tag eLoop q) (Processes q), FilteredLogging (Processes q), HasProcesses e q) => CallbacksEff tag eLoop q -> Eff e (Endpoint tag) Source #

Execute the server loop, that dispatches incoming events to either a set of Callbacks or CallbacksEff.

Since: 0.29.1

data Server tag eLoop e Source #

Phantom type to indicate a callback based Server instance.

Since: 0.27.0

Instances
TangibleCallbacks tag eLoop e => Show (Init (Server tag eLoop e)) Source # 
Instance details

Defined in Control.Eff.Concurrent.Protocol.CallbackServer

Methods

showsPrec :: Int -> Init (Server tag eLoop e) -> ShowS #

show :: Init (Server tag eLoop e) -> String #

showList :: [Init (Server tag eLoop e)] -> ShowS #

TangibleCallbacks tag eLoop e => NFData (Init (Server tag eLoop e)) Source # 
Instance details

Defined in Control.Eff.Concurrent.Protocol.CallbackServer

Methods

rnf :: Init (Server tag eLoop e) -> () #

TangibleCallbacks tag eLoop e => Server (Server tag eLoop e) (Processes e) Source # 
Instance details

Defined in Control.Eff.Concurrent.Protocol.CallbackServer

Associated Types

data Init (Server tag eLoop e) :: Type Source #

type ServerPdu (Server tag eLoop e) :: Type Source #

type ServerEffects (Server tag eLoop e) (Processes e) :: [Type -> Type] Source #

Methods

serverTitle :: Init (Server tag eLoop e) -> ProcessTitle Source #

runEffects :: Endpoint (ServerPdu (Server tag eLoop e)) -> Init (Server tag eLoop e) -> Eff (ServerEffects (Server tag eLoop e) (Processes e)) x -> Eff (Processes e) x Source #

onEvent :: Endpoint (ServerPdu (Server tag eLoop e)) -> Init (Server tag eLoop e) -> Event (ServerPdu (Server tag eLoop e)) -> Eff (ServerEffects (Server tag eLoop e) (Processes e)) () Source #

data Init (Server tag eLoop e) Source # 
Instance details

Defined in Control.Eff.Concurrent.Protocol.CallbackServer

data Init (Server tag eLoop e) = MkServer {}
type ServerPdu (Server tag eLoop e) Source # 
Instance details

Defined in Control.Eff.Concurrent.Protocol.CallbackServer

type ServerPdu (Server tag eLoop e) = tag
type ServerEffects (Server tag eLoop e) (Processes e) Source # 
Instance details

Defined in Control.Eff.Concurrent.Protocol.CallbackServer

type ServerEffects (Server tag eLoop e) (Processes e) = eLoop

newtype ServerId (tag :: Type) Source #

The name/id of a Server for logging purposes.

Since: 0.24.0

Constructors

MkServerId 

Fields

Instances
Eq (ServerId tag) Source # 
Instance details

Defined in Control.Eff.Concurrent.Protocol.CallbackServer

Methods

(==) :: ServerId tag -> ServerId tag -> Bool #

(/=) :: ServerId tag -> ServerId tag -> Bool #

Ord (ServerId tag) Source # 
Instance details

Defined in Control.Eff.Concurrent.Protocol.CallbackServer

Methods

compare :: ServerId tag -> ServerId tag -> Ordering #

(<) :: ServerId tag -> ServerId tag -> Bool #

(<=) :: ServerId tag -> ServerId tag -> Bool #

(>) :: ServerId tag -> ServerId tag -> Bool #

(>=) :: ServerId tag -> ServerId tag -> Bool #

max :: ServerId tag -> ServerId tag -> ServerId tag #

min :: ServerId tag -> ServerId tag -> ServerId tag #

Typeable tag => Show (ServerId tag) Source # 
Instance details

Defined in Control.Eff.Concurrent.Protocol.CallbackServer

Methods

showsPrec :: Int -> ServerId tag -> ShowS #

show :: ServerId tag -> String #

showList :: [ServerId tag] -> ShowS #

IsString (ServerId tag) Source # 
Instance details

Defined in Control.Eff.Concurrent.Protocol.CallbackServer

Methods

fromString :: String -> ServerId tag #

NFData (ServerId tag) Source # 
Instance details

Defined in Control.Eff.Concurrent.Protocol.CallbackServer

Methods

rnf :: ServerId tag -> () #

data Event a where Source #

This event sum-type is used to communicate incoming messages and other events to the instances of Server.

Since: 0.24.0

Constructors

OnCall :: forall a r. (Tangible r, TangiblePdu a (Synchronous r)) => ReplyTarget a r -> Pdu a (Synchronous r) -> Event a

A Synchronous message was received. If an implementation wants to delegate nested Pdus, it can use toEmbeddedReplyTarget to convert a ReplyTarget safely to the embedded protocol.

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 
Instances
Show (Event a) Source # 
Instance details

Defined in Control.Eff.Concurrent.Protocol.EffectfulServer

Methods

showsPrec :: Int -> Event a -> ShowS #

show :: Event a -> String #

showList :: [Event a] -> ShowS #

NFData a => NFData (Event a) Source # 
Instance details

Defined in Control.Eff.Concurrent.Protocol.EffectfulServer

Methods

rnf :: Event a -> () #

type ToPretty (Event a :: Type) Source # 
Instance details

Defined in Control.Eff.Concurrent.Protocol.EffectfulServer

type ToPretty (Event a :: Type) = ToPretty a <+> PutStr "event"

type TangibleCallbacks tag eLoop e = (HasProcesses eLoop e, Typeable e, Typeable eLoop, Typeable tag) Source #

The constraints for a tangible Server instance.

Since: 0.27.0

type Callbacks tag e = CallbacksEff tag (Processes e) e Source #

A convenience type alias for callbacks that do not need a custom effect.

Since: 0.29.1

callbacks :: forall tag q. (HasCallStack, TangibleCallbacks tag (Processes q) q, Server (Server tag (Processes q) q) (Processes q), FilteredLogging q) => (Endpoint tag -> Event tag -> Eff (Processes q) ()) -> ServerId tag -> Callbacks tag q Source #

A smart constructor for Callbacks.

Since: 0.29.1

onEvent :: forall tag q. (HasCallStack, TangibleCallbacks tag (Processes q) q, Server (Server tag (Processes q) q) (Processes q), FilteredLogging q) => (Event tag -> Eff (Processes q) ()) -> ServerId (tag :: Type) -> Callbacks tag q Source #

A simple smart constructor for Callbacks.

Since: 0.29.1

type CallbacksEff tag eLoop e = Init (Server tag eLoop e) Source #

A convenience type alias for effectful callback based Server instances.

See Callbacks.

Since: 0.29.1

callbacksEff :: forall tag eLoop q. (HasCallStack, TangibleCallbacks tag eLoop q, Server (Server tag eLoop q) (Processes q), FilteredLogging q) => (forall x. Endpoint tag -> Eff eLoop x -> Eff (Processes q) x) -> (Endpoint tag -> Event tag -> Eff eLoop ()) -> ServerId tag -> CallbacksEff tag eLoop q Source #

A smart constructor for CallbacksEff.

Since: 0.29.1

onEventEff :: (HasCallStack, TangibleCallbacks tag eLoop q, Server (Server tag eLoop q) (Processes q), FilteredLogging q) => (forall a. Eff eLoop a -> Eff (Processes q) a) -> (Event tag -> Eff eLoop ()) -> ServerId (tag :: Type) -> CallbacksEff tag eLoop q Source #

A simple smart constructor for CallbacksEff.

Since: 0.29.1