top-0.2.4: Top (typed oriented protocol) API

Safe HaskellNone
LanguageHaskell2010

Network.Top.Types

Contents

Synopsis

Top access point configuration

newtype Config Source #

Top's access point configuration

Instances

Default Config Source #

The configuration for the default Top router

Methods

def :: Config #

cfgIP :: Config -> String Source #

Return Top's access point IP

cfgPort :: Config -> Int Source #

Return Top's access point Port

cfgPath :: Config -> String Source #

Return Top's access point Path

def :: Default a => a #

The default value for this type.

Connection Protocols

newtype ByPattern a Source #

A routing protocol specified by a pattern and a type.

Once a connection is established, clients:

  • can send messages of the given type
  • will receive all messages of the same type, that match the given pattern, sent by other agents

Constructors

ByPattern Pattern 

Instances

Eq (ByPattern a) Source # 

Methods

(==) :: ByPattern a -> ByPattern a -> Bool #

(/=) :: ByPattern a -> ByPattern a -> Bool #

Ord (ByPattern a) Source # 
Show (ByPattern a) Source # 
Generic (ByPattern a) Source # 

Associated Types

type Rep (ByPattern a) :: * -> * #

Methods

from :: ByPattern a -> Rep (ByPattern a) x #

to :: Rep (ByPattern a) x -> ByPattern a #

Flat (ByPattern a) Source # 
Model a => Model (ByPattern a) Source # 

Methods

envType :: Proxy * (ByPattern a) -> State Env HType #

type Rep (ByPattern a) Source # 
type Rep (ByPattern a) = D1 (MetaData "ByPattern" "Data.Pattern.Types" "top-0.2.4-7a1nh8xG3Hf47wJEwYUttt" True) (C1 (MetaCons "ByPattern" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Pattern)))

data ByType a Source #

A routing protocol specified by a type.

Once a connection is established, clients:

  • can send messages of the given type
  • will receive all messages of the same type sent by other agents

Constructors

ByType 

Instances

Eq (ByType a) Source # 

Methods

(==) :: ByType a -> ByType a -> Bool #

(/=) :: ByType a -> ByType a -> Bool #

Ord (ByType a) Source # 

Methods

compare :: ByType a -> ByType a -> Ordering #

(<) :: ByType a -> ByType a -> Bool #

(<=) :: ByType a -> ByType a -> Bool #

(>) :: ByType a -> ByType a -> Bool #

(>=) :: ByType a -> ByType a -> Bool #

max :: ByType a -> ByType a -> ByType a #

min :: ByType a -> ByType a -> ByType a #

Show (ByType a) Source # 

Methods

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

show :: ByType a -> String #

showList :: [ByType a] -> ShowS #

Generic (ByType a) Source # 

Associated Types

type Rep (ByType a) :: * -> * #

Methods

from :: ByType a -> Rep (ByType a) x #

to :: Rep (ByType a) x -> ByType a #

Flat (ByType a) Source # 

Methods

encode :: ByType a -> Encoding #

decode :: Get (ByType a) #

size :: ByType a -> NumBits -> NumBits #

Model a => Model (ByType a) Source # 

Methods

envType :: Proxy * (ByType a) -> State Env HType #

type Rep (ByType a) Source # 
type Rep (ByType a) = D1 (MetaData "ByType" "Network.Top.Types" "top-0.2.4-7a1nh8xG3Hf47wJEwYUttt" False) (C1 (MetaCons "ByType" PrefixI False) U1)

byTypeRouter :: Type AbsRef -> TypedBLOB Source #

Return the value of the ByType router identifier for the given type

data ByAny a Source #

A routing protocol to receive all messages.

The ByAny type parameter indicates the type of the messages exchanged on the channel (usually:TypedBLOB).

Once a connection is established, clients:

  • can send messages of any type, as values of the ByAny type argument (for example: an Int value encoded as the corresponding TypedBLOB value)
  • will receive all messages sent by other agents

Constructors

ByAny 

Instances

Eq (ByAny a) Source # 

Methods

(==) :: ByAny a -> ByAny a -> Bool #

(/=) :: ByAny a -> ByAny a -> Bool #

Ord (ByAny a) Source # 

Methods

compare :: ByAny a -> ByAny a -> Ordering #

(<) :: ByAny a -> ByAny a -> Bool #

(<=) :: ByAny a -> ByAny a -> Bool #

(>) :: ByAny a -> ByAny a -> Bool #

(>=) :: ByAny a -> ByAny a -> Bool #

max :: ByAny a -> ByAny a -> ByAny a #

min :: ByAny a -> ByAny a -> ByAny a #

Show (ByAny a) Source # 

Methods

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

show :: ByAny a -> String #

showList :: [ByAny a] -> ShowS #

Generic (ByAny a) Source # 

Associated Types

type Rep (ByAny a) :: * -> * #

Methods

from :: ByAny a -> Rep (ByAny a) x #

to :: Rep (ByAny a) x -> ByAny a #

Flat (ByAny a) Source # 

Methods

encode :: ByAny a -> Encoding #

decode :: Get (ByAny a) #

size :: ByAny a -> NumBits -> NumBits #

Model a => Model (ByAny a) Source # 

Methods

envType :: Proxy * (ByAny a) -> State Env HType #

type Rep (ByAny a) Source # 
type Rep (ByAny a) = D1 (MetaData "ByAny" "Network.Top.Types" "top-0.2.4-7a1nh8xG3Hf47wJEwYUttt" False) (C1 (MetaCons "ByAny" PrefixI False) U1)

byAny :: ByAny TypedBLOB Source #

Shortcut to specify

data Echo a Source #

Echo protocol: any value sent in is returned verbatim to the sender (useful for testing purposes) Client can specify if received messages should be logged (for debugging purposes)

Constructors

Echo 

Fields

Instances

Eq (Echo a) Source # 

Methods

(==) :: Echo a -> Echo a -> Bool #

(/=) :: Echo a -> Echo a -> Bool #

Ord (Echo a) Source # 

Methods

compare :: Echo a -> Echo a -> Ordering #

(<) :: Echo a -> Echo a -> Bool #

(<=) :: Echo a -> Echo a -> Bool #

(>) :: Echo a -> Echo a -> Bool #

(>=) :: Echo a -> Echo a -> Bool #

max :: Echo a -> Echo a -> Echo a #

min :: Echo a -> Echo a -> Echo a #

Show (Echo a) Source # 

Methods

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

show :: Echo a -> String #

showList :: [Echo a] -> ShowS #

Generic (Echo a) Source # 

Associated Types

type Rep (Echo a) :: * -> * #

Methods

from :: Echo a -> Rep (Echo a) x #

to :: Rep (Echo a) x -> Echo a #

Flat (Echo a) Source # 

Methods

encode :: Echo a -> Encoding #

decode :: Get (Echo a) #

size :: Echo a -> NumBits -> NumBits #

Model a => Model (Echo a) Source # 

Methods

envType :: Proxy * (Echo a) -> State Env HType #

type Rep (Echo a) Source # 
type Rep (Echo a) = D1 (MetaData "Echo" "Network.Top.Types" "top-0.2.4-7a1nh8xG3Hf47wJEwYUttt" False) (C1 (MetaCons "Echo" PrefixI True) (S1 (MetaSel (Just Symbol "echoDebug") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool)))

Connection

type App a r = Connection a -> IO r Source #

An application that connects to a channel of type a and eventually returns an IO r

data Connection a Source #

A typed bidirectional connection/channel

Constructors

Connection 

Fields

  • input :: IO a

    Block read till a value is received

  • output :: a -> IO ()

    Block write till a value is sent

  • close :: IO ()

    Close the connection

inputWithTimeout :: Int -> Connection a -> IO (Maybe a) Source #

Return a value received on the connection or Nothing if no value is received in the specified number of seconds

NOTE: In case of timeout, the connection will be closed.

WebSocket Connection

type WSApp r = App ByteString r Source #

An application that connects to a WebSocket channel of type a and eventually returns an IO r

type WSConnection = Connection ByteString Source #

A WebSocket connection

chatsProtocol :: ByteString Source #

CHATS binary identifier

chatsProtocolT :: Text Source #

CHATS textual identifier

CHATS

data ChannelSelectionResult addr Source #

The value returned by an access point, after receiving a routing channel setup request.

Constructors

Success

The channel has been permanently setup to the requested protocol

Failure

The access point is unable or unwilling to open a connection with the requested routing protocol

Fields

RetryAt addr

User should retry with the same transport protocol at the indicated address

Instances

Eq addr => Eq (ChannelSelectionResult addr) Source # 
Ord addr => Ord (ChannelSelectionResult addr) Source # 
Show addr => Show (ChannelSelectionResult addr) Source # 
Generic (ChannelSelectionResult addr) Source # 

Associated Types

type Rep (ChannelSelectionResult addr) :: * -> * #

Flat addr => Flat (ChannelSelectionResult addr) Source # 
Model a => Model (ChannelSelectionResult a) Source # 
type Rep (ChannelSelectionResult addr) Source # 
type Rep (ChannelSelectionResult addr) = D1 (MetaData "ChannelSelectionResult" "Network.Top.Types" "top-0.2.4-7a1nh8xG3Hf47wJEwYUttt" False) ((:+:) (C1 (MetaCons "Success" PrefixI False) U1) ((:+:) (C1 (MetaCons "Failure" PrefixI True) (S1 (MetaSel (Just Symbol "reason") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String))) (C1 (MetaCons "RetryAt" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 addr)))))

Network Addresses

data WebSocketAddress ip Source #

The full address of a WebSocket endpoint

Constructors

WebSocketAddress 

Fields

  • secure :: Bool

    True if the connection is wss (secure), False if is ws

  • host :: SocketAddress ip

    Host endpoint, example: SocketAddress (DNSAddress "quid2.net") (HostPort 80)

  • path :: String

    Path to the WebSocket access point, example: "/ws"

Instances

Eq ip => Eq (WebSocketAddress ip) Source # 
Ord ip => Ord (WebSocketAddress ip) Source # 
Show ip => Show (WebSocketAddress ip) Source # 
Generic (WebSocketAddress ip) Source # 

Associated Types

type Rep (WebSocketAddress ip) :: * -> * #

Flat ip => Flat (WebSocketAddress ip) Source # 
Model ip => Model (WebSocketAddress ip) Source # 
type Rep (WebSocketAddress ip) Source # 
type Rep (WebSocketAddress ip) = D1 (MetaData "WebSocketAddress" "Network.Top.Types" "top-0.2.4-7a1nh8xG3Hf47wJEwYUttt" False) (C1 (MetaCons "WebSocketAddress" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "secure") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Bool)) ((:*:) (S1 (MetaSel (Just Symbol "host") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (SocketAddress ip))) (S1 (MetaSel (Just Symbol "path") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String)))))

data SocketAddress ip Source #

The address of a network socket

Instances

Eq ip => Eq (SocketAddress ip) Source # 
Ord ip => Ord (SocketAddress ip) Source # 
Show ip => Show (SocketAddress ip) Source # 
Generic (SocketAddress ip) Source # 

Associated Types

type Rep (SocketAddress ip) :: * -> * #

Methods

from :: SocketAddress ip -> Rep (SocketAddress ip) x #

to :: Rep (SocketAddress ip) x -> SocketAddress ip #

Flat ip => Flat (SocketAddress ip) Source # 
Model ip => Model (SocketAddress ip) Source # 
type Rep (SocketAddress ip) Source # 
type Rep (SocketAddress ip) = D1 (MetaData "SocketAddress" "Network.Top.Types" "top-0.2.4-7a1nh8xG3Hf47wJEwYUttt" False) (C1 (MetaCons "SocketAddress" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "socketAddress") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (HostAddress ip))) (S1 (MetaSel (Just Symbol "socketPort") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 HostPort))))

data IP4Address Source #

An IP4 address

Instances

Eq IP4Address Source # 
Ord IP4Address Source # 
Show IP4Address Source # 
Generic IP4Address Source # 

Associated Types

type Rep IP4Address :: * -> * #

Flat IP4Address Source # 
Model IP4Address Source # 
Pretty IP4Address Source # 
type Rep IP4Address Source # 

data IP6Address Source #

An IP6 address

Instances

Eq IP6Address Source # 
Ord IP6Address Source # 
Show IP6Address Source # 
Generic IP6Address Source # 

Associated Types

type Rep IP6Address :: * -> * #

Flat IP6Address Source # 
Model IP6Address Source # 
type Rep IP6Address Source # 

data HostAddress ip Source #

A host address, either an IP or a DNS domain

Constructors

IPAddress ip 
DNSAddress String 

Instances

Eq ip => Eq (HostAddress ip) Source # 

Methods

(==) :: HostAddress ip -> HostAddress ip -> Bool #

(/=) :: HostAddress ip -> HostAddress ip -> Bool #

Ord ip => Ord (HostAddress ip) Source # 
Show ip => Show (HostAddress ip) Source # 
Generic (HostAddress ip) Source # 

Associated Types

type Rep (HostAddress ip) :: * -> * #

Methods

from :: HostAddress ip -> Rep (HostAddress ip) x #

to :: Rep (HostAddress ip) x -> HostAddress ip #

Flat ip => Flat (HostAddress ip) Source # 
Model ip => Model (HostAddress ip) Source # 
Pretty ip => Pretty (HostAddress ip) Source # 
type Rep (HostAddress ip) Source # 
type Rep (HostAddress ip) = D1 (MetaData "HostAddress" "Network.Top.Types" "top-0.2.4-7a1nh8xG3Hf47wJEwYUttt" False) ((:+:) (C1 (MetaCons "IPAddress" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ip))) (C1 (MetaCons "DNSAddress" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 String))))

data HostPort Source #

A Sockets port (e.g. 80)

Constructors

HostPort 

Fields

Re-exports

Orphan instances

Lift PRef Source # 

Methods

lift :: PRef -> Q Exp #

Lift a => Lift (Pat a) Source # 

Methods

lift :: Pat a -> Q Exp #