-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Bindings to ZeroMQ 4.x
--   
--   The 0MQ lightweight messaging kernel is a library which extends the
--   standard socket interfaces with features traditionally provided by
--   specialised messaging middleware products.
--   
--   0MQ sockets provide an abstraction of asynchronous message queues,
--   multiple messaging patterns, message filtering (subscriptions),
--   seamless access to multiple transport protocols and more.
--   
--   This library provides the Haskell language binding to 0MQ >= 4.x
@package zeromq4-haskell
@version 0.8.0

-- | Type-level restricted data. This module allows for type declarations
--   which embed certain restrictions, such as value bounds. E.g.
--   Restricted N0 N1 Int denotes an Int which can only
--   have values [0 .. 1]. When creating such a value, the constructor
--   functions restrict or toRestricted ensure that the
--   restrictions are obeyed. Code that consumes restricted types does not
--   need to check the constraints.
--   
--   N.B. This module is more or less tailored to be used within
--   ZMQ3. Therefore the provided type level restrictions are
--   limited.
module Data.Restricted

-- | Type level restriction.
data Restricted r v

-- | A uniform way to restrict values.
class Restriction r v

-- | Create a restricted value. Returns Nothing if the given value
--   does not satisfy all restrictions.
toRestricted :: Restriction r v => v -> Maybe (Restricted r v)

-- | Create a restricted value. If the given value does not satisfy the
--   restrictions, a modified variant is used instead, e.g. if an integer
--   is larger than the upper bound, the upper bound value is used.
restrict :: Restriction r v => v -> Restricted r v

-- | Get the actual value.
rvalue :: Restricted r v -> v

-- | type level -1
data Nneg1

-- | type-level 1
data N1

-- | type-level 0
data N0

-- | type-level 254
data N254

-- | type-level infinity
data Inf

-- | divisable by 4
data Div4

-- | divisable by 5
data Div5
instance Data.Restricted.Restriction Data.Restricted.Div4 Data.ByteString.Internal.Type.ByteString
instance Data.Restricted.Restriction Data.Restricted.Div5 Data.ByteString.Internal.Type.ByteString
instance Data.Restricted.Restriction (Data.Restricted.N1, Data.Restricted.N254) Data.ByteString.Internal.Type.ByteString
instance Data.Restricted.Restriction (Data.Restricted.N0, Data.Restricted.N254) Data.ByteString.Internal.Type.ByteString
instance Data.Restricted.Restriction (Data.Restricted.N1, Data.Restricted.N254) GHC.Internal.Base.String
instance GHC.Internal.Real.Integral a => Data.Restricted.Restriction (Data.Restricted.N0, Data.Restricted.Inf) a
instance GHC.Internal.Real.Integral a => Data.Restricted.Restriction (Data.Restricted.N1, Data.Restricted.Inf) a
instance GHC.Internal.Real.Integral a => Data.Restricted.Restriction (Data.Restricted.Nneg1, Data.Restricted.Inf) a
instance GHC.Internal.Real.Integral a => Data.Restricted.Restriction (Data.Restricted.N1, GHC.Internal.Int.Int32) a
instance GHC.Internal.Real.Integral a => Data.Restricted.Restriction (Data.Restricted.N1, GHC.Internal.Int.Int64) a
instance GHC.Internal.Real.Integral a => Data.Restricted.Restriction (Data.Restricted.N0, GHC.Internal.Int.Int32) a
instance GHC.Internal.Real.Integral a => Data.Restricted.Restriction (Data.Restricted.N0, GHC.Internal.Int.Int64) a
instance GHC.Internal.Real.Integral a => Data.Restricted.Restriction (Data.Restricted.Nneg1, GHC.Internal.Int.Int32) a
instance GHC.Internal.Real.Integral a => Data.Restricted.Restriction (Data.Restricted.Nneg1, GHC.Internal.Int.Int64) a
instance GHC.Internal.Show.Show Data.Restricted.Div4
instance GHC.Internal.Show.Show Data.Restricted.Div5
instance GHC.Internal.Show.Show Data.Restricted.Inf
instance GHC.Internal.Show.Show Data.Restricted.N0
instance GHC.Internal.Show.Show Data.Restricted.N1
instance GHC.Internal.Show.Show Data.Restricted.N254
instance GHC.Internal.Show.Show Data.Restricted.Nneg1
instance GHC.Internal.Show.Show v => GHC.Internal.Show.Show (Data.Restricted.Restricted r v)

-- | Warning: This is an internal module and subject to change
--   without notice.
module System.ZMQ4.Internal.Base
newtype ZMQMsg
ZMQMsg :: Ptr () -> ZMQMsg
[content] :: ZMQMsg -> Ptr ()
data ZMQPoll
ZMQPoll :: {-# UNPACK #-} !ZMQSocket -> {-# UNPACK #-} !CInt -> {-# UNPACK #-} !CShort -> {-# UNPACK #-} !CShort -> ZMQPoll
[pSocket] :: ZMQPoll -> {-# UNPACK #-} !ZMQSocket
[pFd] :: ZMQPoll -> {-# UNPACK #-} !CInt
[pEvents] :: ZMQPoll -> {-# UNPACK #-} !CShort
[pRevents] :: ZMQPoll -> {-# UNPACK #-} !CShort
type ZMQMsgPtr = Ptr ZMQMsg
type ZMQCtx = Ptr ()
type ZMQSocket = Ptr ()
type ZMQPollPtr = Ptr ZMQPoll
newtype ZMQSocketType
ZMQSocketType :: CInt -> ZMQSocketType
[typeVal] :: ZMQSocketType -> CInt
pair :: ZMQSocketType
pub :: ZMQSocketType
sub :: ZMQSocketType
xpub :: ZMQSocketType
xsub :: ZMQSocketType
request :: ZMQSocketType
response :: ZMQSocketType
dealer :: ZMQSocketType
router :: ZMQSocketType
newtype ZMQOption
ZMQOption :: CInt -> ZMQOption
[optVal] :: ZMQOption -> CInt
pull :: ZMQSocketType
push :: ZMQSocketType
stream :: ZMQSocketType
affinity :: ZMQOption
backlog :: ZMQOption
conflate :: ZMQOption
curve :: ZMQOption
curvePublicKey :: ZMQOption
curveSecretKey :: ZMQOption
curveServer :: ZMQOption
curveServerKey :: ZMQOption
delayAttachOnConnect :: ZMQOption
events :: ZMQOption
filedesc :: ZMQOption
identity :: ZMQOption
immediate :: ZMQOption
ipv4Only :: ZMQOption
ipv6 :: ZMQOption
lastEndpoint :: ZMQOption
linger :: ZMQOption
maxMessageSize :: ZMQOption
mcastHops :: ZMQOption
mechanism :: ZMQOption
null :: ZMQOption
plain :: ZMQOption
plainPassword :: ZMQOption
plainServer :: ZMQOption
plainUserName :: ZMQOption
probeRouter :: ZMQOption
rate :: ZMQOption
receiveBuf :: ZMQOption
newtype ZMQCtxOption
ZMQCtxOption :: CInt -> ZMQCtxOption
[ctxOptVal] :: ZMQCtxOption -> CInt
receiveHighWM :: ZMQOption
receiveMore :: ZMQOption
_ioThreads :: ZMQCtxOption
receiveTimeout :: ZMQOption
_maxSockets :: ZMQCtxOption
reconnectIVL :: ZMQOption
reconnectIVLMax :: ZMQOption
recoveryIVL :: ZMQOption
newtype ZMQEventType
ZMQEventType :: Word16 -> ZMQEventType
[eventTypeVal] :: ZMQEventType -> Word16
reqCorrelate :: ZMQOption
reqRelaxed :: ZMQOption
connected :: ZMQEventType
routerMandatory :: ZMQOption
connectDelayed :: ZMQEventType
sendBuf :: ZMQOption
connectRetried :: ZMQEventType
sendHighWM :: ZMQOption
listening :: ZMQEventType
sendTimeout :: ZMQOption
bindFailed :: ZMQEventType
subscribe :: ZMQOption
accepted :: ZMQEventType
tcpAcceptFilter :: ZMQOption
acceptFailed :: ZMQEventType
tcpKeepAlive :: ZMQOption
closed :: ZMQEventType
tcpKeepAliveCount :: ZMQOption
closeFailed :: ZMQEventType
tcpKeepAliveIdle :: ZMQOption
data ZMQEvent
ZMQEvent :: {-# UNPACK #-} !ZMQEventType -> {-# UNPACK #-} !Int32 -> ZMQEvent
[zeEvent] :: ZMQEvent -> {-# UNPACK #-} !ZMQEventType
[zeValue] :: ZMQEvent -> {-# UNPACK #-} !Int32
disconnected :: ZMQEventType
tcpKeepAliveInterval :: ZMQOption
allEvents :: ZMQEventType
unsubscribe :: ZMQOption
monitorStopped :: ZMQEventType
xpubVerbose :: ZMQOption
zapDomain :: ZMQOption
peekZMQEvent :: ZMQMsgPtr -> IO ZMQEvent
newtype ZMQSecMechanism
ZMQSecMechanism :: Int -> ZMQSecMechanism
[secMechanism] :: ZMQSecMechanism -> Int
secNull :: ZMQSecMechanism
secPlain :: ZMQSecMechanism
secCurve :: ZMQSecMechanism
newtype ZMQMsgOption
ZMQMsgOption :: CInt -> ZMQMsgOption
[msgOptVal] :: ZMQMsgOption -> CInt
more :: ZMQMsgOption
newtype ZMQFlag
ZMQFlag :: CInt -> ZMQFlag
[flagVal] :: ZMQFlag -> CInt
dontWait :: ZMQFlag
sndMore :: ZMQFlag
newtype ZMQPollEvent
ZMQPollEvent :: CShort -> ZMQPollEvent
[pollVal] :: ZMQPollEvent -> CShort
pollIn :: ZMQPollEvent
pollOut :: ZMQPollEvent
pollerr :: ZMQPollEvent
c_zmq_version :: Ptr CInt -> Ptr CInt -> Ptr CInt -> IO ()
c_zmq_ctx_new :: IO ZMQCtx
c_zmq_ctx_shutdown :: ZMQCtx -> IO CInt
c_zmq_ctx_term :: ZMQCtx -> IO CInt
c_zmq_ctx_get :: ZMQCtx -> CInt -> IO CInt
c_zmq_ctx_set :: ZMQCtx -> CInt -> CInt -> IO CInt
c_zmq_msg_init :: ZMQMsgPtr -> IO CInt
c_zmq_msg_init_size :: ZMQMsgPtr -> CSize -> IO CInt
c_zmq_msg_close :: ZMQMsgPtr -> IO CInt
c_zmq_msg_data :: ZMQMsgPtr -> IO (Ptr a)
c_zmq_msg_size :: ZMQMsgPtr -> IO CSize
c_zmq_msg_get :: ZMQMsgPtr -> CInt -> IO CInt
c_zmq_msg_set :: ZMQMsgPtr -> CInt -> CInt -> IO CInt
c_zmq_socket :: ZMQCtx -> CInt -> IO ZMQSocket
c_zmq_close :: ZMQSocket -> IO CInt
c_zmq_setsockopt :: ZMQSocket -> CInt -> Ptr () -> CSize -> IO CInt
c_zmq_getsockopt :: ZMQSocket -> CInt -> Ptr () -> Ptr CSize -> IO CInt
c_zmq_bind :: ZMQSocket -> CString -> IO CInt
c_zmq_unbind :: ZMQSocket -> CString -> IO CInt
c_zmq_connect :: ZMQSocket -> CString -> IO CInt
c_zmq_disconnect :: ZMQSocket -> CString -> IO CInt
c_zmq_sendmsg :: ZMQSocket -> ZMQMsgPtr -> CInt -> IO CInt
c_zmq_recvmsg :: ZMQSocket -> ZMQMsgPtr -> CInt -> IO CInt
c_zmq_socket_monitor :: ZMQSocket -> CString -> CInt -> IO CInt
c_zmq_errno :: IO CInt
c_zmq_strerror :: CInt -> IO CString
c_zmq_proxy :: ZMQSocket -> ZMQSocket -> ZMQSocket -> IO CInt
c_zmq_poll :: ZMQPollPtr -> CInt -> CLong -> IO CInt
c_zmq_z85_encode :: CString -> Ptr Word8 -> CSize -> IO CString
c_zmq_z85_decode :: Ptr Word8 -> CString -> IO (Ptr Word8)
c_zmq_curve_keypair :: CString -> CString -> IO CInt
instance GHC.Classes.Eq System.ZMQ4.Internal.Base.ZMQCtxOption
instance GHC.Classes.Eq System.ZMQ4.Internal.Base.ZMQEventType
instance GHC.Classes.Eq System.ZMQ4.Internal.Base.ZMQFlag
instance GHC.Classes.Eq System.ZMQ4.Internal.Base.ZMQMsg
instance GHC.Classes.Eq System.ZMQ4.Internal.Base.ZMQMsgOption
instance GHC.Classes.Eq System.ZMQ4.Internal.Base.ZMQOption
instance GHC.Classes.Eq System.ZMQ4.Internal.Base.ZMQPollEvent
instance GHC.Classes.Eq System.ZMQ4.Internal.Base.ZMQSecMechanism
instance GHC.Classes.Eq System.ZMQ4.Internal.Base.ZMQSocketType
instance GHC.Classes.Ord System.ZMQ4.Internal.Base.ZMQCtxOption
instance GHC.Classes.Ord System.ZMQ4.Internal.Base.ZMQEventType
instance GHC.Classes.Ord System.ZMQ4.Internal.Base.ZMQFlag
instance GHC.Classes.Ord System.ZMQ4.Internal.Base.ZMQMsg
instance GHC.Classes.Ord System.ZMQ4.Internal.Base.ZMQMsgOption
instance GHC.Classes.Ord System.ZMQ4.Internal.Base.ZMQOption
instance GHC.Classes.Ord System.ZMQ4.Internal.Base.ZMQPollEvent
instance GHC.Classes.Ord System.ZMQ4.Internal.Base.ZMQSecMechanism
instance GHC.Classes.Ord System.ZMQ4.Internal.Base.ZMQSocketType
instance GHC.Internal.Show.Show System.ZMQ4.Internal.Base.ZMQEventType
instance GHC.Internal.Show.Show System.ZMQ4.Internal.Base.ZMQSecMechanism
instance GHC.Internal.Foreign.Storable.Storable System.ZMQ4.Internal.Base.ZMQEventType
instance GHC.Internal.Foreign.Storable.Storable System.ZMQ4.Internal.Base.ZMQMsg
instance GHC.Internal.Foreign.Storable.Storable System.ZMQ4.Internal.Base.ZMQPoll

-- | We use our own functions for throwing exceptions in order to get the
--   actual error message via zmq_strerror. 0MQ defines additional
--   error numbers besides those defined by the operating system, so
--   zmq_strerror should be used in preference to
--   strerror which is used by the standard throw* functions in
--   Error.
--   
--   Warning: This is an internal module and subject to change
--   without notice.
module System.ZMQ4.Internal.Error

-- | ZMQError encapsulates information about errors, which occur when using
--   the native 0MQ API, such as error number and message.
data ZMQError
ZMQError :: Int -> String -> String -> ZMQError

-- | Error number value.
[errno] :: ZMQError -> Int

-- | Source where this error originates from.
[source] :: ZMQError -> String

-- | Actual error message.
[message] :: ZMQError -> String
throwError :: String -> IO a
throwIf :: (a -> Bool) -> String -> IO a -> IO a
throwIf_ :: (a -> Bool) -> String -> IO a -> IO ()
throwIfRetry :: (a -> Bool) -> String -> IO a -> IO a
throwIfRetry_ :: (a -> Bool) -> String -> IO a -> IO ()
throwIfMinus1 :: (Eq a, Num a) => String -> IO a -> IO a
throwIfMinus1_ :: (Eq a, Num a) => String -> IO a -> IO ()
throwIfNull :: String -> IO (Ptr a) -> IO (Ptr a)
throwIfMinus1Retry :: (Eq a, Num a) => String -> IO a -> IO a
throwIfMinus1Retry_ :: (Eq a, Num a) => String -> IO a -> IO ()
throwIfRetryMayBlock :: (a -> Bool) -> String -> IO a -> IO b -> IO a
throwIfRetryMayBlock_ :: (a -> Bool) -> String -> IO a -> IO b -> IO ()
throwIfMinus1RetryMayBlock :: (Eq a, Num a) => String -> IO a -> IO b -> IO a
throwIfMinus1RetryMayBlock_ :: (Eq a, Num a) => String -> IO a -> IO b -> IO ()
zmqErrnoMessage :: CInt -> IO String
zmqErrno :: IO Errno
instance GHC.Classes.Eq System.ZMQ4.Internal.Error.ZMQError
instance GHC.Internal.Exception.Type.Exception System.ZMQ4.Internal.Error.ZMQError
instance GHC.Classes.Ord System.ZMQ4.Internal.Error.ZMQError
instance GHC.Internal.Show.Show System.ZMQ4.Internal.Error.ZMQError

-- | Warning: This is an internal module and subject to change
--   without notice.
module System.ZMQ4.Internal

-- | A 0MQ context representation.
newtype Context
Context :: ZMQCtx -> Context
[_ctx] :: Context -> ZMQCtx

-- | A 0MQ Socket.
newtype Socket a
Socket :: SocketRepr -> Socket a
[_socketRepr] :: Socket a -> SocketRepr
data SocketRepr
SocketRepr :: ZMQSocket -> IORef Bool -> SocketRepr
[_socket] :: SocketRepr -> ZMQSocket
[_sockLive] :: SocketRepr -> IORef Bool

-- | Socket types.
class SocketType a
zmqSocketType :: SocketType a => a -> ZMQSocketType
class SocketLike (s :: Type -> Type)
toSocket :: SocketLike s => s t -> Socket t
newtype Message
Message :: ZMQMsgPtr -> Message
[msgPtr] :: Message -> ZMQMsgPtr

-- | Flags to apply on send operations (cf. man zmq_send)
data Flag

-- | ZMQ_DONTWAIT (Only relevant on Windows.)
DontWait :: Flag

-- | ZMQ_SNDMORE
SendMore :: Flag
type Timeout = Int64
type Size = Word

-- | Configuration switch
data Switch

-- | Use default setting
Default :: Switch

-- | Activate setting
On :: Switch

-- | De-activate setting
Off :: Switch

-- | Event types to monitor.
data EventType
ConnectedEvent :: EventType
ConnectDelayedEvent :: EventType
ConnectRetriedEvent :: EventType
ListeningEvent :: EventType
BindFailedEvent :: EventType
AcceptedEvent :: EventType
AcceptFailedEvent :: EventType
ClosedEvent :: EventType
CloseFailedEvent :: EventType
DisconnectedEvent :: EventType
MonitorStoppedEvent :: EventType
AllEvents :: EventType

-- | Event Message to receive when monitoring socket events.
data EventMsg
Connected :: !ByteString -> !Fd -> EventMsg
ConnectDelayed :: !ByteString -> EventMsg
ConnectRetried :: !ByteString -> !Int -> EventMsg
Listening :: !ByteString -> !Fd -> EventMsg
BindFailed :: !ByteString -> !Int -> EventMsg
Accepted :: !ByteString -> !Fd -> EventMsg
AcceptFailed :: !ByteString -> !Int -> EventMsg
Closed :: !ByteString -> !Fd -> EventMsg
CloseFailed :: !ByteString -> !Int -> EventMsg
Disconnected :: !ByteString -> !Fd -> EventMsg
MonitorStopped :: !ByteString -> !Int -> EventMsg
data SecurityMechanism
Null :: SecurityMechanism
Plain :: SecurityMechanism
Curve :: SecurityMechanism
data KeyFormat a
[BinaryFormat] :: KeyFormat Div4
[TextFormat] :: KeyFormat Div5
messageOf :: ByteString -> IO Message
messageOfLazy :: ByteString -> IO Message
messageClose :: Message -> IO ()
messageFree :: Message -> IO ()
messageInit :: IO Message
messageInitSize :: Size -> IO Message
setIntOpt :: (Storable b, Integral b) => Socket a -> ZMQOption -> b -> IO ()
setStrOpt :: Socket a -> ZMQOption -> String -> IO ()
getIntOpt :: (Storable b, Integral b) => Socket a -> ZMQOption -> b -> IO b
getStrOpt :: Socket a -> ZMQOption -> IO String
getInt32Option :: ZMQOption -> Socket a -> IO Int
setInt32OptFromRestricted :: Integral i => ZMQOption -> Restricted r i -> Socket b -> IO ()
ctxIntOption :: Integral i => String -> ZMQCtxOption -> Context -> IO i
setCtxIntOption :: Integral i => String -> ZMQCtxOption -> i -> Context -> IO ()
getBytesOpt :: Socket a -> ZMQOption -> IO ByteString
getByteStringOpt :: Socket a -> ZMQOption -> IO ByteString
setByteStringOpt :: Socket a -> ZMQOption -> ByteString -> IO ()
z85Encode :: MonadIO m => Restricted Div4 ByteString -> m ByteString
z85Decode :: MonadIO m => Restricted Div5 ByteString -> m ByteString
toZMQFlag :: Flag -> ZMQFlag
combine :: (Integral i, Bits i) => [i] -> i
combineFlags :: [Flag] -> CInt
mkSocketRepr :: SocketType t => t -> Context -> IO SocketRepr
closeSock :: SocketRepr -> IO ()
onSocket :: String -> Socket a -> (ZMQSocket -> IO b) -> IO b
bool2cint :: Bool -> CInt
toSwitch :: (Show a, Integral a) => String -> a -> Switch
fromSwitch :: Integral a => Switch -> a
events2cint :: [EventType] -> CInt
eventMessage :: ByteString -> ZMQEvent -> EventMsg
toMechanism :: SecurityMechanism -> ZMQSecMechanism
fromMechanism :: String -> Int -> SecurityMechanism
getKey :: KeyFormat f -> Socket a -> ZMQOption -> IO ByteString
instance GHC.Classes.Eq System.ZMQ4.Internal.EventMsg
instance GHC.Classes.Eq System.ZMQ4.Internal.EventType
instance GHC.Classes.Eq System.ZMQ4.Internal.Flag
instance GHC.Classes.Eq (System.ZMQ4.Internal.KeyFormat a)
instance GHC.Classes.Eq System.ZMQ4.Internal.SecurityMechanism
instance GHC.Classes.Eq System.ZMQ4.Internal.Switch
instance GHC.Classes.Ord System.ZMQ4.Internal.EventType
instance GHC.Classes.Ord System.ZMQ4.Internal.Flag
instance GHC.Classes.Ord System.ZMQ4.Internal.Switch
instance GHC.Internal.Show.Show System.ZMQ4.Internal.EventMsg
instance GHC.Internal.Show.Show System.ZMQ4.Internal.EventType
instance GHC.Internal.Show.Show System.ZMQ4.Internal.Flag
instance GHC.Internal.Show.Show (System.ZMQ4.Internal.KeyFormat a)
instance GHC.Internal.Show.Show System.ZMQ4.Internal.SecurityMechanism
instance GHC.Internal.Show.Show System.ZMQ4.Internal.Switch
instance System.ZMQ4.Internal.SocketLike System.ZMQ4.Internal.Socket

-- | 0MQ haskell binding. The API closely follows the C-API of 0MQ with the
--   main difference being that sockets are typed.
--   
--   Notes
--   
--   Many option settings use a Restriction to further constrain the
--   range of possible values of their integral types. For example the
--   maximum message size can be given as -1, which means no limit or by
--   greater values, which denote the message size in bytes. The type of
--   setMaxMessageSize is therefore:
--   
--   
--   setMaxMessageSize :: Integral i
--                       => Restricted (Nneg1, Int64) i
--                       -> Socket a
--                       -> IO ()
--   
--   
--   which means any integral value in the range of -1 to
--   (maxBound :: Int64) can be given. To create a restricted
--   value from plain value, use toRestricted or restrict.
module System.ZMQ4

-- | ZMQ_PAIR
data Pair
Pair :: Pair

-- | ZMQ_PUB
data Pub
Pub :: Pub

-- | ZMQ_SUB
data Sub
Sub :: Sub

-- | ZMQ_XPUB
data XPub
XPub :: XPub

-- | ZMQ_XSUB
data XSub
XSub :: XSub

-- | ZMQ_REQ
data Req
Req :: Req

-- | ZMQ_REP
data Rep
Rep :: Rep

-- | ZMQ_DEALER
data Dealer
Dealer :: Dealer

-- | ZMQ_ROUTER
data Router
Router :: Router

-- | Deprecated: Use Dealer
type XReq = Dealer

-- | Deprecated: Use Router
type XRep = Router

-- | ZMQ_PULL
data Pull
Pull :: Pull

-- | ZMQ_PUSH
data Push
Push :: Push

-- | ZMQ_STREAM
data Stream
Stream :: Stream

-- | Socket types.
class SocketType a

-- | Sockets which can send.
class Sender a

-- | Sockets which can receive.
class Receiver a

-- | Sockets which can subscribe.
class Subscriber a
class SocketLike (s :: Type -> Type)

-- | Sockets which can be conflated.
class Conflatable a

-- | Sockets which can send probes (cf. setProbeRouter).
class SendProbe a
type Size = Word

-- | A 0MQ context representation.
data Context

-- | A 0MQ Socket.
data Socket a

-- | Flags to apply on send operations (cf. man zmq_send)
data Flag

-- | ZMQ_DONTWAIT (Only relevant on Windows.)
DontWait :: Flag

-- | ZMQ_SNDMORE
SendMore :: Flag

-- | Configuration switch
data Switch

-- | Use default setting
Default :: Switch

-- | Activate setting
On :: Switch

-- | De-activate setting
Off :: Switch
type Timeout = Int64

-- | Socket events.
data Event

-- | ZMQ_POLLIN (incoming messages)
In :: Event

-- | ZMQ_POLLOUT (outgoing messages, i.e. at least 1 byte can be
--   written)
Out :: Event

-- | 
--   ZMQ_POLLERR
--   
Err :: Event

-- | Event types to monitor.
data EventType
ConnectedEvent :: EventType
ConnectDelayedEvent :: EventType
ConnectRetriedEvent :: EventType
ListeningEvent :: EventType
BindFailedEvent :: EventType
AcceptedEvent :: EventType
AcceptFailedEvent :: EventType
ClosedEvent :: EventType
CloseFailedEvent :: EventType
DisconnectedEvent :: EventType
MonitorStoppedEvent :: EventType
AllEvents :: EventType

-- | Event Message to receive when monitoring socket events.
data EventMsg
Connected :: !ByteString -> !Fd -> EventMsg
ConnectDelayed :: !ByteString -> EventMsg
ConnectRetried :: !ByteString -> !Int -> EventMsg
Listening :: !ByteString -> !Fd -> EventMsg
BindFailed :: !ByteString -> !Int -> EventMsg
Accepted :: !ByteString -> !Fd -> EventMsg
AcceptFailed :: !ByteString -> !Int -> EventMsg
Closed :: !ByteString -> !Fd -> EventMsg
CloseFailed :: !ByteString -> !Int -> EventMsg
Disconnected :: !ByteString -> !Fd -> EventMsg
MonitorStopped :: !ByteString -> !Int -> EventMsg

-- | A Poll value contains the object to poll (a 0MQ socket or a
--   file descriptor), the set of Events which are of interest
--   and--optionally-- a callback-function which is invoked iff the set of
--   interested events overlaps with the actual events.
data Poll (s :: Type -> Type) (m :: Type -> Type)
[Sock] :: forall (s :: Type -> Type) t (m :: Type -> Type). s t -> [Event] -> Maybe ([Event] -> m ()) -> Poll s m
[File] :: forall (m :: Type -> Type) (s :: Type -> Type). Fd -> [Event] -> Maybe ([Event] -> m ()) -> Poll s m
data KeyFormat a
[BinaryFormat] :: KeyFormat Div4
[TextFormat] :: KeyFormat Div5
data SecurityMechanism
Null :: SecurityMechanism
Plain :: SecurityMechanism
Curve :: SecurityMechanism

-- | Run an action with a 0MQ context. The Context supplied to your
--   action will not be valid after the action either returns or
--   throws an exception.
withContext :: (Context -> IO a) -> IO a

-- | Run an action with a 0MQ socket. The socket will be closed after
--   running the supplied action even if an error occurs. The socket
--   supplied to your action will not be valid after the action
--   terminates.
withSocket :: SocketType a => Context -> a -> (Socket a -> IO b) -> IO b

-- | Bind the socket to the given address (cf. zmq_bind).
bind :: Socket a -> String -> IO ()

-- | Unbind the socket from the given address (cf. zmq_unbind).
unbind :: Socket a -> String -> IO ()

-- | Connect the socket to the given address (cf. zmq_connect).
connect :: Socket a -> String -> IO ()

-- | Disconnect the socket from the given endpoint (cf.
--   zmq_disconnect).
disconnect :: Socket a -> String -> IO ()

-- | Send the given ByteString over the socket (cf.
--   zmq_sendmsg).
--   
--   Note: This function always calls zmq_sendmsg in a
--   non-blocking way, i.e. there is no need to provide the
--   ZMQ_DONTWAIT flag as this is used by default. Still
--   send is blocking the thread as long as the message can not be
--   queued on the socket using GHC's threadWaitWrite.
send :: Sender a => Socket a -> [Flag] -> ByteString -> IO ()

-- | Send the given ByteString over the socket (cf.
--   zmq_sendmsg).
--   
--   This is operationally identical to send socket (Strict.concat
--   (Lazy.toChunks lbs)) flags but may be more efficient.
--   
--   Note: This function always calls zmq_sendmsg in a
--   non-blocking way, i.e. there is no need to provide the
--   ZMQ_DONTWAIT flag as this is used by default. Still
--   send' is blocking the thread as long as the message can not be
--   queued on the socket using GHC's threadWaitWrite.
send' :: Sender a => Socket a -> [Flag] -> ByteString -> IO ()

-- | Send a multi-part message. This function applies the SendMore
--   Flag between all message parts. 0MQ guarantees atomic delivery
--   of a multi-part message (cf. zmq_sendmsg).
sendMulti :: Sender a => Socket a -> NonEmpty ByteString -> IO ()

-- | Receive a ByteString from socket (cf. zmq_recvmsg).
--   
--   Note: This function always calls zmq_recvmsg in a
--   non-blocking way, i.e. there is no need to provide the
--   ZMQ_DONTWAIT flag as this is used by default. Still
--   receive is blocking the thread as long as no data is available
--   using GHC's threadWaitRead.
receive :: Receiver a => Socket a -> IO ByteString

-- | Receive a multi-part message. This function collects all message parts
--   send via sendMulti.
receiveMulti :: Receiver a => Socket a -> IO [ByteString]

-- | Return the runtime version of the underlying 0MQ library as a (major,
--   minor, patch) triple.
version :: IO (Int, Int, Int)

-- | Monitor socket events (cf. zmq_socket_monitor).
--   
--   This function returns a function which can be invoked to retrieve the
--   next socket event, potentially blocking until the next one becomes
--   available. When applied to False, monitoring will terminate,
--   i.e. internal monitoring resources will be disposed. Consequently
--   after monitor has been invoked, the returned function must be
--   applied once to False.
monitor :: [EventType] -> Context -> Socket a -> IO (Bool -> IO (Maybe EventMsg))

-- | Setup socket monitoring, i.e. a Pair socket which sends
--   monitoring events about the given Socket to the given address.
socketMonitor :: [EventType] -> String -> Socket a -> IO ()

-- | Polls for events on the given Poll descriptors. Returns a list
--   of events per descriptor which have occured. (cf. zmq_poll)
poll :: forall (s :: Type -> Type) m. (SocketLike s, MonadIO m) => Timeout -> [Poll s m] -> m [[Event]]

-- | Subscribe Socket to given subscription.
subscribe :: Subscriber a => Socket a -> ByteString -> IO ()

-- | Unsubscribe Socket from given subscription.
unsubscribe :: Subscriber a => Socket a -> ByteString -> IO ()

-- | zmq_ctx_get ZMQ_IO_THREADS.
ioThreads :: Context -> IO Word

-- | zmq_ctx_get ZMQ_MAX_SOCKETS.
maxSockets :: Context -> IO Word

-- | zmq_ctx_get ZMQ_IO_THREADS.
setIoThreads :: Word -> Context -> IO ()

-- | zmq_ctx_get ZMQ_MAX_SOCKETS.
setMaxSockets :: Word -> Context -> IO ()

-- | zmq_getsockopt ZMQ_AFFINITY.
affinity :: Socket a -> IO Word64

-- | zmq_getsockopt ZMQ_BACKLOG.
backlog :: Socket a -> IO Int

-- | Restricts the outgoing and incoming socket buffers to a single
--   message.
conflate :: Conflatable a => Socket a -> IO Bool

-- | zmq_getsockopt ZMQ_CURVE_PUBLICKEY.
curvePublicKey :: KeyFormat f -> Socket a -> IO ByteString

-- | zmq_getsockopt ZMQ_CURVE_SECRETKEY.
curveSecretKey :: KeyFormat f -> Socket a -> IO ByteString

-- | zmq_getsockopt ZMQ_CURVE_SERVERKEY.
curveServerKey :: KeyFormat f -> Socket a -> IO ByteString

-- | Deprecated: Use immediate
delayAttachOnConnect :: Socket a -> IO Bool

-- | zmq_getsockopt ZMQ_EVENTS.
events :: Socket a -> IO [Event]

-- | zmq_getsockopt ZMQ_FD.
fileDescriptor :: Socket a -> IO Fd

-- | zmq_getsockopt ZMQ_IDENTITY.
identity :: Socket a -> IO ByteString

-- | zmq_getsockopt ZMQ_IMMEDIATE.
immediate :: Socket a -> IO Bool

-- | Deprecated: Use ipv6
ipv4Only :: Socket a -> IO Bool

-- | zmq_getsockopt ZMQ_IPV6.
ipv6 :: Socket a -> IO Bool

-- | zmq_getsockopt ZMQ_LAST_ENDPOINT.
lastEndpoint :: Socket a -> IO String

-- | zmq_getsockopt ZMQ_LINGER.
linger :: Socket a -> IO Int

-- | zmq_getsockopt ZMQ_MAXMSGSIZE.
maxMessageSize :: Socket a -> IO Int64

-- | zmq_getsockopt ZMQ_MULTICAST_HOPS.
mcastHops :: Socket a -> IO Int

-- | zmq_getsockopt ZMQ_MECHANISM.
mechanism :: Socket a -> IO SecurityMechanism

-- | zmq_getsockopt ZMQ_RCVMORE.
moreToReceive :: Socket a -> IO Bool

-- | zmq_getsockopt ZMQ_PLAIN_SERVER.
plainServer :: Socket a -> IO Bool

-- | zmq_getsockopt ZMQ_PLAIN_PASSWORD.
plainPassword :: Socket a -> IO ByteString

-- | zmq_getsockopt ZMQ_PLAIN_USERNAME.
plainUserName :: Socket a -> IO ByteString

-- | zmq_getsockopt ZMQ_RATE.
rate :: Socket a -> IO Int

-- | zmq_getsockopt ZMQ_RCVBUF.
receiveBuffer :: Socket a -> IO Int

-- | zmq_getsockopt ZMQ_RCVHWM.
receiveHighWM :: Socket a -> IO Int

-- | zmq_getsockopt ZMQ_RCVTIMEO.
receiveTimeout :: Socket a -> IO Int

-- | zmq_getsockopt ZMQ_RECONNECT_IVL.
reconnectInterval :: Socket a -> IO Int

-- | zmq_getsockopt ZMQ_RECONNECT_IVL_MAX.
reconnectIntervalMax :: Socket a -> IO Int

-- | zmq_getsockopt ZMQ_RECOVERY_IVL.
recoveryInterval :: Socket a -> IO Int

-- | zmq_getsockopt ZMQ_SNDBUF.
sendBuffer :: Socket a -> IO Int

-- | zmq_getsockopt ZMQ_SNDHWM.
sendHighWM :: Socket a -> IO Int

-- | zmq_getsockopt ZMQ_SNDTIMEO.
sendTimeout :: Socket a -> IO Int

-- | zmq_getsockopt ZMQ_TCP_KEEPALIVE.
tcpKeepAlive :: Socket a -> IO Switch

-- | zmq_getsockopt ZMQ_TCP_KEEPALIVE_CNT.
tcpKeepAliveCount :: Socket a -> IO Int

-- | zmq_getsockopt ZMQ_TCP_KEEPALIVE_IDLE.
tcpKeepAliveIdle :: Socket a -> IO Int

-- | zmq_getsockopt ZMQ_TCP_KEEPALIVE_INTVL.
tcpKeepAliveInterval :: Socket a -> IO Int

-- | zmq_getsockopt ZMQ_ZAP_DOMAIN.
zapDomain :: Socket a -> IO ByteString

-- | zmq_setsockopt ZMQ_AFFINITY.
setAffinity :: Word64 -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_BACKLOG.
setBacklog :: Integral i => Restricted (N0, Int32) i -> Socket a -> IO ()

-- | Restrict the outgoing and incoming socket buffers to a single message.
setConflate :: Conflatable a => Bool -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_CURVE_SERVER.
setCurveServer :: Bool -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_CURVE_PUBLICKEY.
setCurvePublicKey :: KeyFormat f -> Restricted f ByteString -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_CURVE_SECRETKEY.
setCurveSecretKey :: KeyFormat f -> Restricted f ByteString -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_CURVE_SERVERKEY.
setCurveServerKey :: KeyFormat f -> Restricted f ByteString -> Socket a -> IO ()

-- | Deprecated: Use setImmediate
setDelayAttachOnConnect :: Bool -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_IDENTITY.
setIdentity :: Restricted (N1, N254) ByteString -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_IMMEDIATE.
setImmediate :: Bool -> Socket a -> IO ()

-- | Deprecated: Use setIpv6
setIpv4Only :: Bool -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_IPV6.
setIpv6 :: Bool -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_LINGER.
setLinger :: Integral i => Restricted (Nneg1, Int32) i -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_MAXMSGSIZE.
setMaxMessageSize :: Integral i => Restricted (Nneg1, Int64) i -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_MULTICAST_HOPS.
setMcastHops :: Integral i => Restricted (N1, Int32) i -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_PLAIN_SERVER.
setPlainServer :: Bool -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_PLAIN_USERNAME.
setPlainPassword :: Restricted (N1, N254) ByteString -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_PLAIN_USERNAME.
setPlainUserName :: Restricted (N1, N254) ByteString -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_PROBE_ROUTER.
setProbeRouter :: SendProbe a => Bool -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_RATE.
setRate :: Integral i => Restricted (N1, Int32) i -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_RCVBUF.
setReceiveBuffer :: Integral i => Restricted (N0, Int32) i -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_RCVHWM.
setReceiveHighWM :: Integral i => Restricted (N0, Int32) i -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_RCVTIMEO.
setReceiveTimeout :: Integral i => Restricted (Nneg1, Int32) i -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_RECONNECT_IVL.
setReconnectInterval :: Integral i => Restricted (N0, Int32) i -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_RECONNECT_IVL_MAX.
setReconnectIntervalMax :: Integral i => Restricted (N0, Int32) i -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_RECOVERY_IVL.
setRecoveryInterval :: Integral i => Restricted (N0, Int32) i -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_REQ_CORRELATE.
setReqCorrelate :: Bool -> Socket Req -> IO ()

-- | zmq_setsockopt ZMQ_REQ_RELAXED.
setReqRelaxed :: Bool -> Socket Req -> IO ()

-- | zmq_setsockopt ZMQ_ROUTER_MANDATORY.
setRouterMandatory :: Bool -> Socket Router -> IO ()

-- | zmq_setsockopt ZMQ_SNDBUF.
setSendBuffer :: Integral i => Restricted (N0, Int32) i -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_SNDHWM.
setSendHighWM :: Integral i => Restricted (N0, Int32) i -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_SNDTIMEO.
setSendTimeout :: Integral i => Restricted (Nneg1, Int32) i -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_TCP_ACCEPT_FILTER.
setTcpAcceptFilter :: Maybe ByteString -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_TCP_KEEPALIVE.
setTcpKeepAlive :: Switch -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_TCP_KEEPALIVE_CNT.
setTcpKeepAliveCount :: Integral i => Restricted (Nneg1, Int32) i -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_TCP_KEEPALIVE_IDLE.
setTcpKeepAliveIdle :: Integral i => Restricted (Nneg1, Int32) i -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_TCP_KEEPALIVE_INTVL.
setTcpKeepAliveInterval :: Integral i => Restricted (Nneg1, Int32) i -> Socket a -> IO ()

-- | zmq_setsockopt ZMQ_XPUB_VERBOSE.
setXPubVerbose :: Bool -> Socket XPub -> IO ()

-- | zmq_getsockopt ZMQ_ZAP_DOMAIN.
setZapDomain :: Restricted (N1, N254) ByteString -> Socket a -> IO ()

-- | Create a restricted value. If the given value does not satisfy the
--   restrictions, a modified variant is used instead, e.g. if an integer
--   is larger than the upper bound, the upper bound value is used.
restrict :: Restriction r v => v -> Restricted r v

-- | Create a restricted value. Returns Nothing if the given value
--   does not satisfy all restrictions.
toRestricted :: Restriction r v => v -> Maybe (Restricted r v)

-- | ZMQError encapsulates information about errors, which occur when using
--   the native 0MQ API, such as error number and message.
data ZMQError

-- | Error number value.
errno :: ZMQError -> Int

-- | Source where this error originates from.
source :: ZMQError -> String

-- | Actual error message.
message :: ZMQError -> String

-- | Deprecated: Use context
init :: Size -> IO Context

-- | Terminate a 0MQ context. Equivalent to zmq_ctx_term.
term :: Context -> IO ()

-- | Shutdown a 0MQ context. Equivalent to zmq_ctx_shutdown.
shutdown :: Context -> IO ()

-- | Initialize a 0MQ context. Equivalent to zmq_ctx_new.
context :: IO Context

-- | Create a new 0MQ socket within the given context. withSocket
--   provides automatic socket closing and may be safer to use.
socket :: SocketType a => Context -> a -> IO (Socket a)

-- | Close a 0MQ socket. withSocket provides automatic socket
--   closing and may be safer to use.
close :: Socket a -> IO ()

-- | Wait until data is available for reading from the given Socket. After
--   this function returns, a call to receive will essentially be
--   non-blocking.
waitRead :: Socket a -> IO ()

-- | Wait until data can be written to the given Socket. After this
--   function returns, a call to send will essentially be
--   non-blocking.
waitWrite :: Socket a -> IO ()
z85Encode :: MonadIO m => Restricted Div4 ByteString -> m ByteString
z85Decode :: MonadIO m => Restricted Div5 ByteString -> m ByteString

-- | Starts built-in 0MQ proxy (cf. zmq_proxy)
--   
--   Proxy connects front to back socket
--   
--   Before calling proxy all sockets should be bound
--   
--   If the capture socket is not Nothing, the proxy shall send all
--   messages, received on both frontend and backend, to the capture
--   socket.
proxy :: Socket a -> Socket b -> Maybe (Socket c) -> IO ()

-- | Generate a new curve key pair. (cf. zmq_curve_keypair)
curveKeyPair :: MonadIO m => m (Restricted Div5 ByteString, Restricted Div5 ByteString)
instance System.ZMQ4.Conflatable System.ZMQ4.Dealer
instance System.ZMQ4.Conflatable System.ZMQ4.Pub
instance System.ZMQ4.Conflatable System.ZMQ4.Pull
instance System.ZMQ4.Conflatable System.ZMQ4.Push
instance System.ZMQ4.Conflatable System.ZMQ4.Sub
instance GHC.Classes.Eq System.ZMQ4.Dealer
instance GHC.Classes.Eq System.ZMQ4.Event
instance GHC.Classes.Eq System.ZMQ4.Pair
instance GHC.Classes.Eq System.ZMQ4.Pub
instance GHC.Classes.Eq System.ZMQ4.Pull
instance GHC.Classes.Eq System.ZMQ4.Push
instance GHC.Classes.Eq System.ZMQ4.Rep
instance GHC.Classes.Eq System.ZMQ4.Req
instance GHC.Classes.Eq System.ZMQ4.Router
instance GHC.Classes.Eq System.ZMQ4.Stream
instance GHC.Classes.Eq System.ZMQ4.Sub
instance GHC.Classes.Eq System.ZMQ4.XPub
instance GHC.Classes.Eq System.ZMQ4.XSub
instance GHC.Internal.Generics.Generic System.ZMQ4.Dealer
instance GHC.Internal.Generics.Generic System.ZMQ4.Pair
instance GHC.Internal.Generics.Generic System.ZMQ4.Pub
instance GHC.Internal.Generics.Generic System.ZMQ4.Pull
instance GHC.Internal.Generics.Generic System.ZMQ4.Push
instance GHC.Internal.Generics.Generic System.ZMQ4.Rep
instance GHC.Internal.Generics.Generic System.ZMQ4.Req
instance GHC.Internal.Generics.Generic System.ZMQ4.Router
instance GHC.Internal.Generics.Generic System.ZMQ4.Stream
instance GHC.Internal.Generics.Generic System.ZMQ4.Sub
instance GHC.Internal.Generics.Generic System.ZMQ4.XPub
instance GHC.Internal.Generics.Generic System.ZMQ4.XSub
instance GHC.Classes.Ord System.ZMQ4.Event
instance GHC.Internal.Read.Read System.ZMQ4.Event
instance System.ZMQ4.Receiver System.ZMQ4.Dealer
instance System.ZMQ4.Receiver System.ZMQ4.Pair
instance System.ZMQ4.Receiver System.ZMQ4.Pull
instance System.ZMQ4.Receiver System.ZMQ4.Rep
instance System.ZMQ4.Receiver System.ZMQ4.Req
instance System.ZMQ4.Receiver System.ZMQ4.Router
instance System.ZMQ4.Receiver System.ZMQ4.Stream
instance System.ZMQ4.Receiver System.ZMQ4.Sub
instance System.ZMQ4.Receiver System.ZMQ4.XPub
instance System.ZMQ4.Receiver System.ZMQ4.XSub
instance System.ZMQ4.SendProbe System.ZMQ4.Dealer
instance System.ZMQ4.SendProbe System.ZMQ4.Req
instance System.ZMQ4.SendProbe System.ZMQ4.Router
instance System.ZMQ4.Sender System.ZMQ4.Dealer
instance System.ZMQ4.Sender System.ZMQ4.Pair
instance System.ZMQ4.Sender System.ZMQ4.Pub
instance System.ZMQ4.Sender System.ZMQ4.Push
instance System.ZMQ4.Sender System.ZMQ4.Rep
instance System.ZMQ4.Sender System.ZMQ4.Req
instance System.ZMQ4.Sender System.ZMQ4.Router
instance System.ZMQ4.Sender System.ZMQ4.Stream
instance System.ZMQ4.Sender System.ZMQ4.XPub
instance System.ZMQ4.Sender System.ZMQ4.XSub
instance GHC.Internal.Show.Show System.ZMQ4.Event
instance System.ZMQ4.Internal.SocketType System.ZMQ4.Dealer
instance System.ZMQ4.Internal.SocketType System.ZMQ4.Pair
instance System.ZMQ4.Internal.SocketType System.ZMQ4.Pub
instance System.ZMQ4.Internal.SocketType System.ZMQ4.Pull
instance System.ZMQ4.Internal.SocketType System.ZMQ4.Push
instance System.ZMQ4.Internal.SocketType System.ZMQ4.Rep
instance System.ZMQ4.Internal.SocketType System.ZMQ4.Req
instance System.ZMQ4.Internal.SocketType System.ZMQ4.Router
instance System.ZMQ4.Internal.SocketType System.ZMQ4.Stream
instance System.ZMQ4.Internal.SocketType System.ZMQ4.Sub
instance System.ZMQ4.Internal.SocketType System.ZMQ4.XPub
instance System.ZMQ4.Internal.SocketType System.ZMQ4.XSub
instance System.ZMQ4.Subscriber System.ZMQ4.Sub

-- | This modules exposes a monadic interface of ZMQ4. Actions run
--   inside a ZMQ monad and Sockets are guaranteed not to
--   leak outside their corresponding runZMQ scope. Running
--   ZMQ computations asynchronously is directly supported through
--   async.
module System.ZMQ4.Monadic

-- | The ZMQ monad is modeled after ST and encapsulates a
--   Context. It uses the uninstantiated type variable z to
--   distinguish different invoctions of runZMQ and to prevent
--   unintented use of Sockets outside their scope. Cf. the paper of
--   John Launchbury and Simon Peyton Jones Lazy Functional State
--   Threads.
data ZMQ z a

-- | The ZMQ socket, parameterised by SocketType and belonging to
--   a particular ZMQ thread.
data Socket z t

-- | Flags to apply on send operations (cf. man zmq_send)
data Flag

-- | ZMQ_DONTWAIT (Only relevant on Windows.)
DontWait :: Flag

-- | ZMQ_SNDMORE
SendMore :: Flag

-- | Configuration switch
data Switch

-- | Use default setting
Default :: Switch

-- | Activate setting
On :: Switch

-- | De-activate setting
Off :: Switch
type Timeout = Int64

-- | Socket events.
data Event

-- | ZMQ_POLLIN (incoming messages)
In :: Event

-- | ZMQ_POLLOUT (outgoing messages, i.e. at least 1 byte can be
--   written)
Out :: Event

-- | 
--   ZMQ_POLLERR
--   
Err :: Event

-- | Event types to monitor.
data EventType
ConnectedEvent :: EventType
ConnectDelayedEvent :: EventType
ConnectRetriedEvent :: EventType
ListeningEvent :: EventType
BindFailedEvent :: EventType
AcceptedEvent :: EventType
AcceptFailedEvent :: EventType
ClosedEvent :: EventType
CloseFailedEvent :: EventType
DisconnectedEvent :: EventType
MonitorStoppedEvent :: EventType
AllEvents :: EventType

-- | Event Message to receive when monitoring socket events.
data EventMsg
Connected :: !ByteString -> !Fd -> EventMsg
ConnectDelayed :: !ByteString -> EventMsg
ConnectRetried :: !ByteString -> !Int -> EventMsg
Listening :: !ByteString -> !Fd -> EventMsg
BindFailed :: !ByteString -> !Int -> EventMsg
Accepted :: !ByteString -> !Fd -> EventMsg
AcceptFailed :: !ByteString -> !Int -> EventMsg
Closed :: !ByteString -> !Fd -> EventMsg
CloseFailed :: !ByteString -> !Int -> EventMsg
Disconnected :: !ByteString -> !Fd -> EventMsg
MonitorStopped :: !ByteString -> !Int -> EventMsg

-- | A Poll value contains the object to poll (a 0MQ socket or a
--   file descriptor), the set of Events which are of interest
--   and--optionally-- a callback-function which is invoked iff the set of
--   interested events overlaps with the actual events.
data Poll (s :: Type -> Type) (m :: Type -> Type)
[Sock] :: forall (s :: Type -> Type) t (m :: Type -> Type). s t -> [Event] -> Maybe ([Event] -> m ()) -> Poll s m
[File] :: forall (m :: Type -> Type) (s :: Type -> Type). Fd -> [Event] -> Maybe ([Event] -> m ()) -> Poll s m
data KeyFormat a
[BinaryFormat] :: KeyFormat Div4
[TextFormat] :: KeyFormat Div5
data SecurityMechanism
Null :: SecurityMechanism
Plain :: SecurityMechanism
Curve :: SecurityMechanism

-- | Socket types.
class SocketType a

-- | Sockets which can send.
class Sender a

-- | Sockets which can receive.
class Receiver a

-- | Sockets which can subscribe.
class Subscriber a
class SocketLike (s :: Type -> Type)

-- | Sockets which can be conflated.
class Conflatable a

-- | Sockets which can send probes (cf. setProbeRouter).
class SendProbe a

-- | ZMQ_PAIR
data Pair
Pair :: Pair

-- | ZMQ_PUB
data Pub
Pub :: Pub

-- | ZMQ_SUB
data Sub
Sub :: Sub

-- | ZMQ_XPUB
data XPub
XPub :: XPub

-- | ZMQ_XSUB
data XSub
XSub :: XSub

-- | ZMQ_REQ
data Req
Req :: Req

-- | ZMQ_REP
data Rep
Rep :: Rep

-- | ZMQ_DEALER
data Dealer
Dealer :: Dealer

-- | ZMQ_ROUTER
data Router
Router :: Router

-- | ZMQ_PULL
data Pull
Pull :: Pull

-- | ZMQ_PUSH
data Push
Push :: Push

-- | ZMQ_STREAM
data Stream
Stream :: Stream
version :: ZMQ z (Int, Int, Int)

-- | Return the value computed by the given ZMQ monad. Rank-2
--   polymorphism is used to prevent leaking of z. An invocation
--   of runZMQ will internally create a Context and all
--   actions are executed relative to this context. On finish the context
--   will be disposed, but see async.
runZMQ :: MonadIO m => (forall z. () => ZMQ z a) -> m a

-- | Run the given ZMQ computation asynchronously, i.e. this
--   function runs the computation in a new thread using async.
--   N.B. reference counting is used to prolong the lifetime of the
--   Context encapsulated in ZMQ as necessary, e.g.:
--   
--   
--   runZMQ $ do
--       s <- socket Pair
--       async $ do
--           liftIO (threadDelay 10000000)
--           identity s >>= liftIO . print
--   
--   
--   Here, runZMQ will finish before the code section in
--   async, but due to reference counting, the Context will
--   only be disposed after async finishes as well.
async :: ZMQ z a -> ZMQ z (Async a)
socket :: SocketType t => t -> ZMQ z (Socket z t)
ioThreads :: ZMQ z Word
maxSockets :: ZMQ z Word
setIoThreads :: Word -> ZMQ z ()
setMaxSockets :: Word -> ZMQ z ()
close :: Socket z t -> ZMQ z ()
bind :: Socket z t -> String -> ZMQ z ()
unbind :: Socket z t -> String -> ZMQ z ()
connect :: Socket z t -> String -> ZMQ z ()
disconnect :: Socket z t -> String -> ZMQ z ()
send :: Sender t => Socket z t -> [Flag] -> ByteString -> ZMQ z ()
send' :: Sender t => Socket z t -> [Flag] -> ByteString -> ZMQ z ()
sendMulti :: Sender t => Socket z t -> NonEmpty ByteString -> ZMQ z ()
receive :: Receiver t => Socket z t -> ZMQ z ByteString
receiveMulti :: Receiver t => Socket z t -> ZMQ z [ByteString]
subscribe :: Subscriber t => Socket z t -> ByteString -> ZMQ z ()
unsubscribe :: Subscriber t => Socket z t -> ByteString -> ZMQ z ()
proxy :: Socket z a -> Socket z b -> Maybe (Socket z c) -> ZMQ z ()
monitor :: [EventType] -> Socket z t -> ZMQ z (Bool -> IO (Maybe EventMsg))
socketMonitor :: [EventType] -> String -> Socket z t -> ZMQ z ()

-- | Polls for events on the given Poll descriptors. Returns a list
--   of events per descriptor which have occured. (cf. zmq_poll)
poll :: forall (s :: Type -> Type) m. (SocketLike s, MonadIO m) => Timeout -> [Poll s m] -> m [[Event]]
affinity :: Socket z t -> ZMQ z Word64
backlog :: Socket z t -> ZMQ z Int
conflate :: Conflatable t => Socket z t -> ZMQ z Bool
curvePublicKey :: KeyFormat f -> Socket z t -> ZMQ z ByteString
curveSecretKey :: KeyFormat f -> Socket z t -> ZMQ z ByteString
curveServerKey :: KeyFormat f -> Socket z t -> ZMQ z ByteString

-- | Deprecated: Use immediate
delayAttachOnConnect :: Socket z t -> ZMQ z Bool
events :: Socket z t -> ZMQ z [Event]
fileDescriptor :: Socket z t -> ZMQ z Fd
identity :: Socket z t -> ZMQ z ByteString
immediate :: Socket z t -> ZMQ z Bool

-- | Deprecated: Use ipv6
ipv4Only :: Socket z t -> ZMQ z Bool
ipv6 :: Socket z t -> ZMQ z Bool
lastEndpoint :: Socket z t -> ZMQ z String
linger :: Socket z t -> ZMQ z Int
maxMessageSize :: Socket z t -> ZMQ z Int64
mcastHops :: Socket z t -> ZMQ z Int
mechanism :: Socket z t -> ZMQ z SecurityMechanism
moreToReceive :: Socket z t -> ZMQ z Bool
plainServer :: Socket z t -> ZMQ z Bool
plainPassword :: Socket z t -> ZMQ z ByteString
plainUserName :: Socket z t -> ZMQ z ByteString
rate :: Socket z t -> ZMQ z Int
receiveBuffer :: Socket z t -> ZMQ z Int
receiveHighWM :: Socket z t -> ZMQ z Int
receiveTimeout :: Socket z t -> ZMQ z Int
reconnectInterval :: Socket z t -> ZMQ z Int
reconnectIntervalMax :: Socket z t -> ZMQ z Int
recoveryInterval :: Socket z t -> ZMQ z Int
sendBuffer :: Socket z t -> ZMQ z Int
sendHighWM :: Socket z t -> ZMQ z Int
sendTimeout :: Socket z t -> ZMQ z Int
tcpKeepAlive :: Socket z t -> ZMQ z Switch
tcpKeepAliveCount :: Socket z t -> ZMQ z Int
tcpKeepAliveIdle :: Socket z t -> ZMQ z Int
tcpKeepAliveInterval :: Socket z t -> ZMQ z Int
zapDomain :: Socket z t -> ZMQ z ByteString
setAffinity :: Word64 -> Socket z t -> ZMQ z ()
setBacklog :: Integral i => Restricted (N0, Int32) i -> Socket z t -> ZMQ z ()
setConflate :: Conflatable t => Bool -> Socket z t -> ZMQ z ()
setCurveServer :: Bool -> Socket z t -> ZMQ z ()
setCurvePublicKey :: KeyFormat f -> Restricted f ByteString -> Socket z t -> ZMQ z ()
setCurveSecretKey :: KeyFormat f -> Restricted f ByteString -> Socket z t -> ZMQ z ()
setCurveServerKey :: KeyFormat f -> Restricted f ByteString -> Socket z t -> ZMQ z ()

-- | Deprecated: Use setImmediate
setDelayAttachOnConnect :: Bool -> Socket z t -> ZMQ z ()
setIdentity :: Restricted (N1, N254) ByteString -> Socket z t -> ZMQ z ()
setImmediate :: Bool -> Socket z t -> ZMQ z ()

-- | Deprecated: Use setIpv6
setIpv4Only :: Bool -> Socket z t -> ZMQ z ()
setIpv6 :: Bool -> Socket z t -> ZMQ z ()
setLinger :: Integral i => Restricted (Nneg1, Int32) i -> Socket z t -> ZMQ z ()
setMaxMessageSize :: Integral i => Restricted (Nneg1, Int64) i -> Socket z t -> ZMQ z ()
setMcastHops :: Integral i => Restricted (N1, Int32) i -> Socket z t -> ZMQ z ()
setPlainServer :: Bool -> Socket z t -> ZMQ z ()
setPlainPassword :: Restricted (N1, N254) ByteString -> Socket z t -> ZMQ z ()
setPlainUserName :: Restricted (N1, N254) ByteString -> Socket z t -> ZMQ z ()
setProbeRouter :: SendProbe t => Bool -> Socket z t -> ZMQ z ()
setRate :: Integral i => Restricted (N1, Int32) i -> Socket z t -> ZMQ z ()
setReceiveBuffer :: Integral i => Restricted (N0, Int32) i -> Socket z t -> ZMQ z ()
setReceiveHighWM :: Integral i => Restricted (N0, Int32) i -> Socket z t -> ZMQ z ()
setReceiveTimeout :: Integral i => Restricted (Nneg1, Int32) i -> Socket z t -> ZMQ z ()
setReconnectInterval :: Integral i => Restricted (N0, Int32) i -> Socket z t -> ZMQ z ()
setReconnectIntervalMax :: Integral i => Restricted (N0, Int32) i -> Socket z t -> ZMQ z ()
setRecoveryInterval :: Integral i => Restricted (N0, Int32) i -> Socket z t -> ZMQ z ()
setReqCorrelate :: Bool -> Socket z Req -> ZMQ z ()
setReqRelaxed :: Bool -> Socket z Req -> ZMQ z ()
setRouterMandatory :: Bool -> Socket z Router -> ZMQ z ()
setSendBuffer :: Integral i => Restricted (N0, Int32) i -> Socket z t -> ZMQ z ()
setSendHighWM :: Integral i => Restricted (N0, Int32) i -> Socket z t -> ZMQ z ()
setSendTimeout :: Integral i => Restricted (Nneg1, Int32) i -> Socket z t -> ZMQ z ()
setTcpAcceptFilter :: Maybe ByteString -> Socket z t -> ZMQ z ()
setTcpKeepAlive :: Switch -> Socket z t -> ZMQ z ()
setTcpKeepAliveCount :: Integral i => Restricted (Nneg1, Int32) i -> Socket z t -> ZMQ z ()
setTcpKeepAliveIdle :: Integral i => Restricted (Nneg1, Int32) i -> Socket z t -> ZMQ z ()
setTcpKeepAliveInterval :: Integral i => Restricted (Nneg1, Int32) i -> Socket z t -> ZMQ z ()
setXPubVerbose :: Bool -> Socket z XPub -> ZMQ z ()
setZapDomain :: Restricted (N1, N254) ByteString -> Socket z t -> ZMQ z ()

-- | ZMQError encapsulates information about errors, which occur when using
--   the native 0MQ API, such as error number and message.
data ZMQError

-- | Error number value.
errno :: ZMQError -> Int

-- | Source where this error originates from.
source :: ZMQError -> String

-- | Actual error message.
message :: ZMQError -> String

-- | Lift a computation from the IO monad. This allows us to run IO
--   computations in any monadic stack, so long as it supports these kinds
--   of operations (i.e. IO is the base monad for the stack).
--   
--   
Example
--   
--   
--   import Control.Monad.Trans.State -- from the "transformers" library
--   
--   printState :: Show s => StateT s IO ()
--   printState = do
--     state <- get
--     liftIO $ print state
--   
--   
--   Had we omitted liftIO, we would have ended up with
--   this error:
--   
--   
--   • Couldn't match type ‘IO’ with ‘StateT s IO’
--    Expected type: StateT s IO ()
--      Actual type: IO ()
--   
--   
--   The important part here is the mismatch between StateT s IO
--   () and IO ().
--   
--   Luckily, we know of a function that takes an IO a and
--   returns an (m a): liftIO, enabling us to run
--   the program and see the expected results:
--   
--   
--   > evalStateT printState "hello"
--   "hello"
--   
--   > evalStateT printState 3
--   3
--   
liftIO :: MonadIO m => IO a -> m a

-- | Create a restricted value. If the given value does not satisfy the
--   restrictions, a modified variant is used instead, e.g. if an integer
--   is larger than the upper bound, the upper bound value is used.
restrict :: Restriction r v => v -> Restricted r v

-- | Create a restricted value. Returns Nothing if the given value
--   does not satisfy all restrictions.
toRestricted :: Restriction r v => v -> Maybe (Restricted r v)
waitRead :: Socket z t -> ZMQ z ()
waitWrite :: Socket z t -> ZMQ z ()
z85Encode :: MonadIO m => Restricted Div4 ByteString -> m ByteString
z85Decode :: MonadIO m => Restricted Div5 ByteString -> m ByteString

-- | Generate a new curve key pair. (cf. zmq_curve_keypair)
curveKeyPair :: MonadIO m => m (Restricted Div5 ByteString, Restricted Div5 ByteString)
instance GHC.Internal.Base.Applicative (System.ZMQ4.Monadic.ZMQ z)
instance GHC.Internal.Base.Functor (System.ZMQ4.Monadic.ZMQ z)
instance Control.Monad.Trans.Control.MonadBaseControl GHC.Types.IO (System.ZMQ4.Monadic.ZMQ z)
instance Control.Monad.Base.MonadBase GHC.Types.IO (System.ZMQ4.Monadic.ZMQ z)
instance Control.Monad.Catch.MonadCatch (System.ZMQ4.Monadic.ZMQ z)
instance Control.Monad.IO.Class.MonadIO (System.ZMQ4.Monadic.ZMQ z)
instance Control.Monad.Catch.MonadMask (System.ZMQ4.Monadic.ZMQ z)
instance Control.Monad.Catch.MonadThrow (System.ZMQ4.Monadic.ZMQ z)
instance GHC.Internal.Base.Monad (System.ZMQ4.Monadic.ZMQ z)
instance System.ZMQ4.Internal.SocketLike (System.ZMQ4.Monadic.Socket z)
