patterns-0.1.1: Common patterns in message-oriented applications

Safe HaskellNone




Fundamental streaming types



type RIO = ResourceT IOSource

The IO Resource transformer. See the conduit package for details

type Source = Source RIO ByteStringSource

A stream source

type Sink = Sink ByteString RIO ()Source

A stream sink without return type

type SinkR r = Sink ByteString RIO rSource

A stream sink wit return type

type Conduit o r = ConduitM ByteString o RIO rSource

A conduit that links source and sink applying some transformation to the stream. Input is always ByteString, output and return type may vary.

type Conduit_ = Conduit ByteString ()Source

Simplified Conduit where output is always ByteString and no final value is returned.

streamList :: [ByteString] -> Producer RIO ByteStringSource

Streaming the elements of a list

passThrough :: Conduit ByteString ()Source

Pass the stream through without applying any transformation to it

Link Type

data LinkType Source

A zeromq AccessPoint can be bound or connected to its address. Only one peer can bind the address, all other parties have to connect.



Bind the address


Connect to the address

Error Handling

type OnError_ = Criticality -> SomeException -> String -> IO ()Source

Error handler for all services that are implemented as background services, e.g. servers and brokers. The handler receives the Criticality of the error event, the exception and an additional descriptive string.

A good policy is to terminate or restart the service when a Fatal or Critical error occurs and to continue, if possible, on a plain Error. The error handler may perform additional, user-defined actions, such as logging the incident or sending an SMS.

data Criticality Source

Indicates criticality of the error event



The current operation (e.g. processing a request) has not terminated properly, but the service is able to continue; the error may have been caused by a faulty request or other temporal conditions.


The event has impact on the process, leaving it in an unkown state.


The service cannot recover and will terminate

data StreamException Source

Stream Exception


SocketExc String

low-level error

IOExc String

IO error

ProtocolExc String

Protocol error

AppExc String

Application-defined error

Ouch String

Internal error, indicating a code error in library

Some convenient definitions

type Identifier = StringSource

String identifying a stream in the streams device

type Service = StringSource

String identifying a service provided, e.g. by a server

type Identity = ByteStringSource

Identity of a communication peer, needed for complex patterns (e.g. broker)

type Body = [ByteString]Source

Message body, needed for complex patterns (e.g. broker)

type Msec = IntSource


type Timeout = TimeoutSource

Reexport from zeromq (timeout in microseconds)

type Context = ContextSource

Reexport from zeromq

type Size = SizeSource

Reexport from zeromq

withContext :: Size -> (Context -> IO a) -> IO aSource

Reexport from zeromq