AERN-Net-0.2.0: Compositional lazy dataflow networks for exact real number computationSource codeContentsIndex
Control.ERNet.Foundations.Channel
Portabilityportable
Stabilityexperimental
Maintainermik@konecny.aow.cz
Description

Abstraction of data flow channels and its sockets with associated query-answer protocol for gradual data communication.

To be imported qualified, usually with the prefix CH.

Synopsis
class Channel sIn sOut sInAnyProt sOutAnyProt | sIn -> sOut sInAnyProt sOutAnyProt, sOut -> sIn sInAnyProt sOutAnyProt, sInAnyProt -> sOutAnyProt sIn sOut, sOutAnyProt -> sInAnyProt sIn sOut where
castIn :: QAProtocol q a => String -> sInAnyProt -> sIn q a
castOut :: QAProtocol q a => String -> sOutAnyProt -> sOut q a
castInIO :: QAProtocol q a => String -> sInAnyProt -> IO (sIn q a)
castOutIO :: QAProtocol q a => String -> sOutAnyProt -> IO (sOut q a)
makeQuery :: (QAProtocol q a, Show q, Show a) => sOut q2 a2 -> QueryId -> sIn q a -> q -> IO QueryId
makeQueryAnyProt :: String -> sOutAnyProt -> QueryId -> sInAnyProt -> QueryAnyProt -> IO QueryId
waitForQuery :: (QAProtocol q a, Show q, Show a) => sOut q a -> IO (QueryId, q)
waitForQueryMulti :: [sOutAnyProt] -> IO (Int, (QueryId, QueryAnyProt))
answerQuery :: QAProtocol q a => Bool -> sOut q a -> (QueryId, a) -> IO ()
answerQueryAnyProt :: String -> Bool -> sOutAnyProt -> (QueryId, AnswerAnyProt) -> IO ()
waitForAnswer :: (QAProtocol q a, Show q, Show a) => sOut q2 a2 -> QueryId -> sIn q a -> QueryId -> IO a
waitForAnswerMulti :: sOutAnyProt -> QueryId -> [(sInAnyProt, QueryId)] -> IO (Int, AnswerAnyProt)
class (Channel sIn sOut sInAnyProt sOutAnyProt, Logger lg) => ChannelForScheduler lg sIn sOut sInAnyProt sOutAnyProt | sIn -> lg where
new :: lg -> String -> Int -> ChannelType -> IO (sInAnyProt, sOutAnyProt)
Documentation
class Channel sIn sOut sInAnyProt sOutAnyProt | sIn -> sOut sInAnyProt sOutAnyProt, sOut -> sIn sInAnyProt sOutAnyProt, sInAnyProt -> sOutAnyProt sIn sOut, sOutAnyProt -> sInAnyProt sIn sOut whereSource

A channel type, as it is presented to the processes, consists of an input socket and an output socket types.

Each socket type has a unique protocol associated with it. Whenever the protocol can be determined at compile time, we use the sIn and sOut types, otherwise we use the sInAnyProt and sOutAnyProt types. Elements of sInAnyProt and sOutAnyProt can be dynamically cast to elements of sIn and sOut once the protocol can be deduced by the Haskell type checker.

Methods
castInSource
:: QAProtocol q a
=> Stringplace where function used; for error messages
-> sInAnyProt
-> sIn q a
castOutSource
:: QAProtocol q a
=> Stringplace where function used; for error messages
-> sOutAnyProt
-> sOut q a
castInIOSource
:: QAProtocol q a
=> Stringplace where function used; for error messages
-> sInAnyProt
-> IO (sIn q a)
castOutIOSource
:: QAProtocol q a
=> Stringplace where function used; for error messages
-> sOutAnyProt
-> IO (sOut q a)
makeQuerySource
:: (QAProtocol q a, Show q, Show a)
=> sOut q2 a2initiator query socket
-> QueryIdthe query to the initiator that this query reacts to
-> sIn q asocket to send query to
-> qthe query data
-> IO QueryIdquery ID to be able to match the answers with queries

Register a new query on the given socket. Return the new query's id.

This is a version using a statically typed protocol.

makeQueryAnyProtSource
:: Stringplace where function used; for error messages
-> sOutAnyProtinitiator query socket
-> QueryIdthe query to the initiator that this query reacts to
-> sInAnyProtsocket to send query to
-> QueryAnyProtthe query data
-> IO QueryIdquery ID to be able to match the answers with queries

Register a new query on the given socket. Return the new query's id.

This is a version using a dynamically typed protocol.

waitForQuerySource
:: (QAProtocol q a, Show q, Show a)
=> sOut q aoutput socket to wait on
-> IO (QueryId, q)

Wait until the given socket has at least one new query. When there is at least one, return the earliest one and set its status to pending.

This function uses a statically typed protocol.

waitForQueryMultiSource
:: [sOutAnyProt]output sockets to wait on
-> IO (Int, (QueryId, QueryAnyProt))

Wait until one of the given sockets has at least one new query. When there is at least one, return the earliest one and set its status to pending.

This is function uses a dynamically typed protocol.

answerQuerySource
:: QAProtocol q a
=> Boolshould the answer be cached?
-> sOut q a
-> (QueryId, a)
-> IO ()

Send the provided answer to the given socket as an answer to the query with the given query ID.

This is a version using a statically typed protocol.

answerQueryAnyProtSource
:: Stringplace where function used; for error messages
-> Boolshould the answer be cached?
-> sOutAnyProt
-> (QueryId, AnswerAnyProt)
-> IO ()

Send the provided answer to the given socket as an answer to the query with the given query ID.

This is a version using a dynamically typed protocol.

waitForAnswerSource
:: (QAProtocol q a, Show q, Show a)
=> sOut q2 a2initiator query socket
-> QueryIdthe query to the initiator that this query reacted to
-> sIn q a
-> QueryId
-> IO a
Wait for an answer to a query with the given query ID.
waitForAnswerMultiSource
:: sOutAnyProtinitiator query socket
-> QueryIdthe query to the initiator that all of these queries reacted to
-> [(sInAnyProt, QueryId)]
-> IO (Int, AnswerAnyProt)
Wait for an answer to one of several queries with the given query IDs.
show/hide Instances
class (Channel sIn sOut sInAnyProt sOutAnyProt, Logger lg) => ChannelForScheduler lg sIn sOut sInAnyProt sOutAnyProt | sIn -> lg whereSource
Methods
newSource
:: lga logger to use by the new channel
-> Stringname of channel responder process
-> Intchannel id
-> ChannelTypeused to determine the embedded instance of QAProtocol
-> IO (sInAnyProt, sOutAnyProt)the channel's input and output sockets
create a new channel that is then given to processes
show/hide Instances
Produced by Haddock version 2.4.2