    {-# LINE 1 "src/System/ZMQ4/Internal/Base.hsc" #-}
    {-# LANGUAGE CPP                        #-}
    {-# LANGUAGE ForeignFunctionInterface   #-}
    {-# LANGUAGE GeneralizedNewtypeDeriving #-}

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

    import Foreign
    import Foreign.C.Types
    import Foreign.C.String
    import Control.Applicative
    import Prelude

    {-# LINE 20 "src/System/ZMQ4/Internal/Base.hsc" #-}

    -----------------------------------------------------------------------------
    -- Message

    newtype ZMQMsg = ZMQMsg
      { ZMQMsg -> Ptr ()
    content :: Ptr ()
      } deriving (ZMQMsg -> ZMQMsg -> Bool
    (ZMQMsg -> ZMQMsg -> Bool)
    -> (ZMQMsg -> ZMQMsg -> Bool) -> Eq ZMQMsg
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ZMQMsg -> ZMQMsg -> Bool
    == :: ZMQMsg -> ZMQMsg -> Bool
    $c/= :: ZMQMsg -> ZMQMsg -> Bool
    /= :: ZMQMsg -> ZMQMsg -> Bool
    Eq, Eq ZMQMsg
    Eq ZMQMsg =>
    (ZMQMsg -> ZMQMsg -> Ordering)
    -> (ZMQMsg -> ZMQMsg -> Bool)
    -> (ZMQMsg -> ZMQMsg -> Bool)
    -> (ZMQMsg -> ZMQMsg -> Bool)
    -> (ZMQMsg -> ZMQMsg -> Bool)
    -> (ZMQMsg -> ZMQMsg -> ZMQMsg)
    -> (ZMQMsg -> ZMQMsg -> ZMQMsg)
    -> Ord ZMQMsg
    ZMQMsg -> ZMQMsg -> Bool
    ZMQMsg -> ZMQMsg -> Ordering
    ZMQMsg -> ZMQMsg -> ZMQMsg
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: ZMQMsg -> ZMQMsg -> Ordering
    compare :: ZMQMsg -> ZMQMsg -> Ordering
    $c< :: ZMQMsg -> ZMQMsg -> Bool
    < :: ZMQMsg -> ZMQMsg -> Bool
    $c<= :: ZMQMsg -> ZMQMsg -> Bool
    <= :: ZMQMsg -> ZMQMsg -> Bool
    $c> :: ZMQMsg -> ZMQMsg -> Bool
    > :: ZMQMsg -> ZMQMsg -> Bool
    $c>= :: ZMQMsg -> ZMQMsg -> Bool
    >= :: ZMQMsg -> ZMQMsg -> Bool
    $cmax :: ZMQMsg -> ZMQMsg -> ZMQMsg
    max :: ZMQMsg -> ZMQMsg -> ZMQMsg
    $cmin :: ZMQMsg -> ZMQMsg -> ZMQMsg
    min :: ZMQMsg -> ZMQMsg -> ZMQMsg
    Ord)

    instance Storable ZMQMsg where
        alignment :: ZMQMsg -> Int
    alignment ZMQMsg
    _        = Int
    8
    {-# LINE 30 "src/System/ZMQ4/Internal/Base.hsc" #-}
        sizeOf    _        = (64)
    {-# LINE 31 "src/System/ZMQ4/Internal/Base.hsc" #-}
        peek p             = ZMQMsg <$> (\hsc_ptr -> peekByteOff hsc_ptr 0) p
    {-# LINE 32 "src/System/ZMQ4/Internal/Base.hsc" #-}
        poke p (ZMQMsg c)  = (\hsc_ptr -> pokeByteOff hsc_ptr 0) p c
    {-# LINE 33 "src/System/ZMQ4/Internal/Base.hsc" #-}

    -----------------------------------------------------------------------------
    -- Poll

    data ZMQPoll = ZMQPoll
        { ZMQPoll -> Ptr ()
    pSocket  :: {-# UNPACK #-} !ZMQSocket
        , ZMQPoll -> CInt
    pFd      :: {-# UNPACK #-} !CInt
        , ZMQPoll -> CShort
    pEvents  :: {-# UNPACK #-} !CShort
        , ZMQPoll -> CShort
    pRevents :: {-# UNPACK #-} !CShort
        }

    instance Storable ZMQPoll where
        alignment :: ZMQPoll -> Int
    alignment ZMQPoll
    _ = Int
    8
    {-# LINE 46 "src/System/ZMQ4/Internal/Base.hsc" #-}
        sizeOf    _ = (16)
    {-# LINE 47 "src/System/ZMQ4/Internal/Base.hsc" #-}
        peek p = do
            s  <- (\hsc_ptr -> peekByteOff hsc_ptr 0) p
    {-# LINE 49 "src/System/ZMQ4/Internal/Base.hsc" #-}
            f  <- (\hsc_ptr -> peekByteOff hsc_ptr 8) p
    {-# LINE 50 "src/System/ZMQ4/Internal/Base.hsc" #-}
            e  <- (\hsc_ptr -> peekByteOff hsc_ptr 12) p
    {-# LINE 51 "src/System/ZMQ4/Internal/Base.hsc" #-}
            re <- (\hsc_ptr -> peekByteOff hsc_ptr 14) p
    {-# LINE 52 "src/System/ZMQ4/Internal/Base.hsc" #-}
            return $ ZMQPoll s f e re
        poke :: Ptr ZMQPoll -> ZMQPoll -> IO ()
    poke Ptr ZMQPoll
    p (ZMQPoll Ptr ()
    s CInt
    f CShort
    e CShort
    re) = do
            (\Ptr ZMQPoll
    hsc_ptr -> Ptr ZMQPoll -> Int -> Ptr () -> IO ()
    forall b. Ptr b -> Int -> Ptr () -> IO ()
    forall a b. Storable a => Ptr b -> Int -> a -> IO ()
    pokeByteOff Ptr ZMQPoll
    hsc_ptr Int
    0) Ptr ZMQPoll
    p Ptr ()
    s
    {-# LINE 55 "src/System/ZMQ4/Internal/Base.hsc" #-}
            (\Ptr ZMQPoll
    hsc_ptr -> Ptr ZMQPoll -> Int -> CInt -> IO ()
    forall b. Ptr b -> Int -> CInt -> IO ()
    forall a b. Storable a => Ptr b -> Int -> a -> IO ()
    pokeByteOff Ptr ZMQPoll
    hsc_ptr Int
    8) Ptr ZMQPoll
    p CInt
    f
    {-# LINE 56 "src/System/ZMQ4/Internal/Base.hsc" #-}
            (\Ptr ZMQPoll
    hsc_ptr -> Ptr ZMQPoll -> Int -> CShort -> IO ()
    forall b. Ptr b -> Int -> CShort -> IO ()
    forall a b. Storable a => Ptr b -> Int -> a -> IO ()
    pokeByteOff Ptr ZMQPoll
    hsc_ptr Int
    12) Ptr ZMQPoll
    p CShort
    e
    {-# LINE 57 "src/System/ZMQ4/Internal/Base.hsc" #-}
            (\Ptr ZMQPoll
    hsc_ptr -> Ptr ZMQPoll -> Int -> CShort -> IO ()
    forall b. Ptr b -> Int -> CShort -> IO ()
    forall a b. Storable a => Ptr b -> Int -> a -> IO ()
    pokeByteOff Ptr ZMQPoll
    hsc_ptr Int
    14) Ptr ZMQPoll
    p CShort
    re
    {-# LINE 58 "src/System/ZMQ4/Internal/Base.hsc" #-}

    type ZMQMsgPtr  = Ptr ZMQMsg
    type ZMQCtx     = Ptr ()
    type ZMQSocket  = Ptr ()
    type ZMQPollPtr = Ptr ZMQPoll

    {-# LINE 67 "src/System/ZMQ4/Internal/Base.hsc" #-}

    -----------------------------------------------------------------------------
    -- Socket Types

    newtype ZMQSocketType = ZMQSocketType
      { ZMQSocketType -> CInt
    typeVal :: CInt
      } deriving (ZMQSocketType -> ZMQSocketType -> Bool
    (ZMQSocketType -> ZMQSocketType -> Bool)
    -> (ZMQSocketType -> ZMQSocketType -> Bool) -> Eq ZMQSocketType
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ZMQSocketType -> ZMQSocketType -> Bool
    == :: ZMQSocketType -> ZMQSocketType -> Bool
    $c/= :: ZMQSocketType -> ZMQSocketType -> Bool
    /= :: ZMQSocketType -> ZMQSocketType -> Bool
    Eq, Eq ZMQSocketType
    Eq ZMQSocketType =>
    (ZMQSocketType -> ZMQSocketType -> Ordering)
    -> (ZMQSocketType -> ZMQSocketType -> Bool)
    -> (ZMQSocketType -> ZMQSocketType -> Bool)
    -> (ZMQSocketType -> ZMQSocketType -> Bool)
    -> (ZMQSocketType -> ZMQSocketType -> Bool)
    -> (ZMQSocketType -> ZMQSocketType -> ZMQSocketType)
    -> (ZMQSocketType -> ZMQSocketType -> ZMQSocketType)
    -> Ord ZMQSocketType
    ZMQSocketType -> ZMQSocketType -> Bool
    ZMQSocketType -> ZMQSocketType -> Ordering
    ZMQSocketType -> ZMQSocketType -> ZMQSocketType
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: ZMQSocketType -> ZMQSocketType -> Ordering
    compare :: ZMQSocketType -> ZMQSocketType -> Ordering
    $c< :: ZMQSocketType -> ZMQSocketType -> Bool
    < :: ZMQSocketType -> ZMQSocketType -> Bool
    $c<= :: ZMQSocketType -> ZMQSocketType -> Bool
    <= :: ZMQSocketType -> ZMQSocketType -> Bool
    $c> :: ZMQSocketType -> ZMQSocketType -> Bool
    > :: ZMQSocketType -> ZMQSocketType -> Bool
    $c>= :: ZMQSocketType -> ZMQSocketType -> Bool
    >= :: ZMQSocketType -> ZMQSocketType -> Bool
    $cmax :: ZMQSocketType -> ZMQSocketType -> ZMQSocketType
    max :: ZMQSocketType -> ZMQSocketType -> ZMQSocketType
    $cmin :: ZMQSocketType -> ZMQSocketType -> ZMQSocketType
    min :: ZMQSocketType -> ZMQSocketType -> ZMQSocketType
    Ord)

    pair      :: ZMQSocketType
    pair :: ZMQSocketType
    pair      = CInt -> ZMQSocketType
    ZMQSocketType CInt
    0
    pub       :: ZMQSocketType
    pub :: ZMQSocketType
    pub       = CInt -> ZMQSocketType
    ZMQSocketType CInt
    1
    sub       :: ZMQSocketType
    sub :: ZMQSocketType
    sub       = CInt -> ZMQSocketType
    ZMQSocketType CInt
    2
    xpub      :: ZMQSocketType
    xpub :: ZMQSocketType
    xpub      = CInt -> ZMQSocketType
    ZMQSocketType CInt
    9
    xsub      :: ZMQSocketType
    xsub :: ZMQSocketType
    xsub      = CInt -> ZMQSocketType
    ZMQSocketType CInt
    10
    request   :: ZMQSocketType
    request :: ZMQSocketType
    request   = CInt -> ZMQSocketType
    ZMQSocketType CInt
    3
    response  :: ZMQSocketType
    response :: ZMQSocketType
    response  = CInt -> ZMQSocketType
    ZMQSocketType CInt
    4
    dealer    :: ZMQSocketType
    dealer :: ZMQSocketType
    dealer    = CInt -> ZMQSocketType
    ZMQSocketType CInt
    5
    router    :: ZMQSocketType
    router :: ZMQSocketType
    router    = CInt -> ZMQSocketType
    ZMQSocketType CInt
    6
    pull      :: ZMQSocketType
    pull :: ZMQSocketType
    pull      = CInt -> ZMQSocketType
    ZMQSocketType CInt
    7
    push      :: ZMQSocketType
    push :: ZMQSocketType
    push      = CInt -> ZMQSocketType
    ZMQSocketType CInt
    8
    stream    :: ZMQSocketType
    stream :: ZMQSocketType
    stream    = CInt -> ZMQSocketType
    ZMQSocketType CInt
    11

    {-# LINE 89 "src/System/ZMQ4/Internal/Base.hsc" #-}

    -----------------------------------------------------------------------------
    -- Socket Options

    newtype ZMQOption = ZMQOption
      { optVal :: CInt
      } deriving (Eq, Ord)

    affinity              :: ZMQOption
    affinity              = ZMQOption 4
    backlog               :: ZMQOption
    backlog               = ZMQOption 19
    conflate              :: ZMQOption
    conflate :: ZMQOption
    conflate              = CInt -> ZMQOption
    ZMQOption CInt
    54
    curve                 :: ZMQOption
    curve :: ZMQOption
    curve                 = CInt -> ZMQOption
    ZMQOption CInt
    2
    curvePublicKey        :: ZMQOption
    curvePublicKey :: ZMQOption
    curvePublicKey        = CInt -> ZMQOption
    ZMQOption CInt
    48
    curveSecretKey        :: ZMQOption
    curveSecretKey :: ZMQOption
    curveSecretKey        = CInt -> ZMQOption
    ZMQOption CInt
    49
    curveServer           :: ZMQOption
    curveServer :: ZMQOption
    curveServer           = CInt -> ZMQOption
    ZMQOption CInt
    47
    curveServerKey        :: ZMQOption
    curveServerKey :: ZMQOption
    curveServerKey        = CInt -> ZMQOption
    ZMQOption CInt
    50
    delayAttachOnConnect  :: ZMQOption
    delayAttachOnConnect :: ZMQOption
    delayAttachOnConnect  = CInt -> ZMQOption
    ZMQOption CInt
    39
    events                :: ZMQOption
    events :: ZMQOption
    events                = CInt -> ZMQOption
    ZMQOption CInt
    15
    filedesc              :: ZMQOption
    filedesc :: ZMQOption
    filedesc              = CInt -> ZMQOption
    ZMQOption CInt
    14
    identity              :: ZMQOption
    identity :: ZMQOption
    identity              = CInt -> ZMQOption
    ZMQOption CInt
    5
    immediate             :: ZMQOption
    immediate :: ZMQOption
    immediate             = CInt -> ZMQOption
    ZMQOption CInt
    39
    ipv4Only              :: ZMQOption
    ipv4Only :: ZMQOption
    ipv4Only              = CInt -> ZMQOption
    ZMQOption CInt
    31
    ipv6                  :: ZMQOption
    ipv6 :: ZMQOption
    ipv6                  = CInt -> ZMQOption
    ZMQOption CInt
    42
    lastEndpoint          :: ZMQOption
    lastEndpoint :: ZMQOption
    lastEndpoint          = CInt -> ZMQOption
    ZMQOption CInt
    32
    linger                :: ZMQOption
    linger :: ZMQOption
    linger                = CInt -> ZMQOption
    ZMQOption CInt
    17
    maxMessageSize        :: ZMQOption
    maxMessageSize :: ZMQOption
    maxMessageSize        = CInt -> ZMQOption
    ZMQOption CInt
    22
    mcastHops             :: ZMQOption
    mcastHops :: ZMQOption
    mcastHops             = CInt -> ZMQOption
    ZMQOption CInt
    25
    mechanism             :: ZMQOption
    mechanism :: ZMQOption
    mechanism             = CInt -> ZMQOption
    ZMQOption CInt
    43
    null                  :: ZMQOption
    null :: ZMQOption
    null                  = CInt -> ZMQOption
    ZMQOption CInt
    0
    plain                 :: ZMQOption
    plain :: ZMQOption
    plain                 = CInt -> ZMQOption
    ZMQOption CInt
    1
    plainPassword         :: ZMQOption
    plainPassword :: ZMQOption
    plainPassword         = CInt -> ZMQOption
    ZMQOption CInt
    46
    plainServer           :: ZMQOption
    plainServer :: ZMQOption
    plainServer           = CInt -> ZMQOption
    ZMQOption CInt
    44
    plainUserName         :: ZMQOption
    plainUserName :: ZMQOption
    plainUserName         = CInt -> ZMQOption
    ZMQOption CInt
    45
    probeRouter           :: ZMQOption
    probeRouter :: ZMQOption
    probeRouter           = CInt -> ZMQOption
    ZMQOption CInt
    51
    rate                  :: ZMQOption
    rate :: ZMQOption
    rate                  = CInt -> ZMQOption
    ZMQOption CInt
    8
    receiveBuf            :: ZMQOption
    receiveBuf :: ZMQOption
    receiveBuf            = CInt -> ZMQOption
    ZMQOption CInt
    12
    receiveHighWM         :: ZMQOption
    receiveHighWM         = ZMQOption 24
    receiveMore           :: ZMQOption
    receiveMore :: ZMQOption
    receiveMore           = CInt -> ZMQOption
    ZMQOption CInt
    13
    receiveTimeout        :: ZMQOption
    receiveTimeout :: ZMQOption
    receiveTimeout        = CInt -> ZMQOption
    ZMQOption CInt
    27
    reconnectIVL          :: ZMQOption
    reconnectIVL :: ZMQOption
    reconnectIVL          = CInt -> ZMQOption
    ZMQOption CInt
    18
    reconnectIVLMax       :: ZMQOption
    reconnectIVLMax :: ZMQOption
    reconnectIVLMax       = CInt -> ZMQOption
    ZMQOption CInt
    21
    recoveryIVL           :: ZMQOption
    recoveryIVL :: ZMQOption
    recoveryIVL           = CInt -> ZMQOption
    ZMQOption CInt
    9
    reqCorrelate          :: ZMQOption
    reqCorrelate          = ZMQOption 52
    reqRelaxed            :: ZMQOption
    reqRelaxed :: ZMQOption
    reqRelaxed            = CInt -> ZMQOption
    ZMQOption CInt
    53
    routerMandatory       :: ZMQOption
    routerMandatory :: ZMQOption
    routerMandatory       = CInt -> ZMQOption
    ZMQOption CInt
    33
    sendBuf               :: ZMQOption
    sendBuf :: ZMQOption
    sendBuf               = CInt -> ZMQOption
    ZMQOption CInt
    11
    sendHighWM            :: ZMQOption
    sendHighWM :: ZMQOption
    sendHighWM            = CInt -> ZMQOption
    ZMQOption CInt
    23
    sendTimeout           :: ZMQOption
    sendTimeout :: ZMQOption
    sendTimeout           = CInt -> ZMQOption
    ZMQOption CInt
    28
    subscribe             :: ZMQOption
    subscribe :: ZMQOption
    subscribe             = CInt -> ZMQOption
    ZMQOption CInt
    6
    tcpAcceptFilter       :: ZMQOption
    tcpAcceptFilter :: ZMQOption
    tcpAcceptFilter       = CInt -> ZMQOption
    ZMQOption CInt
    38
    acceptFailed :: ZMQEventType
    tcpKeepAlive          :: ZMQOption
    tcpKeepAlive :: ZMQOption
    tcpKeepAlive          = CInt -> ZMQOption
    ZMQOption CInt
    34
    tcpKeepAliveCount     :: ZMQOption
    tcpKeepAliveCount :: ZMQOption
    tcpKeepAliveCount     = CInt -> ZMQOption
    ZMQOption CInt
    35
    tcpKeepAliveIdle      :: ZMQOption
    tcpKeepAliveIdle :: ZMQOption
    tcpKeepAliveIdle      = ZMQOption 36
    tcpKeepAliveInterval  :: ZMQOption
    tcpKeepAliveInterval :: ZMQOption
    tcpKeepAliveInterval  = ZMQOption 37
    unsubscribe           :: ZMQOption
    unsubscribe :: ZMQOption
    unsubscribe           = CInt -> ZMQOption
    ZMQOption CInt
    7
    xpubVerbose           :: ZMQOption
    xpubVerbose :: ZMQOption
    xpubVerbose           = CInt -> ZMQOption
    ZMQOption CInt
    40
    zapDomain             :: ZMQOption
    zapDomain :: ZMQOption
    zapDomain             = CInt -> ZMQOption
    ZMQOption CInt
    55

    {-# LINE 148 "src/System/ZMQ4/Internal/Base.hsc" #-}

    -----------------------------------------------------------------------------
    -- Context Options

    newtype ZMQCtxOption = ZMQCtxOption
      { ctxOptVal :: CInt
      } deriving (Eq, Ord)

    _ioThreads  :: ZMQCtxOption
    _ioThreads  = ZMQCtxOption 1
    _maxSockets  :: ZMQCtxOption
    _maxSockets  = ZMQCtxOption 2

    {-# LINE 160 "src/System/ZMQ4/Internal/Base.hsc" #-}

    -----------------------------------------------------------------------------
    -- Event Type

    newtype ZMQEventType = ZMQEventType
      { eventTypeVal :: Word16
      } deriving (Eq, Ord, Show, Storable)

    connected       :: ZMQEventType
    connected       = ZMQEventType 1
    connectDelayed  :: ZMQEventType
    connectDelayed  = ZMQEventType 2
    connectRetried  :: ZMQEventType
    connectRetried  = ZMQEventType 4
    listening       :: ZMQEventType
    listening       = ZMQEventType 8
    bindFailed      :: ZMQEventType
    bindFailed      = ZMQEventType 16
    accepted        :: ZMQEventType
    accepted        = ZMQEventType 32
    acceptFailed    :: ZMQEventType
    acceptFailed    = ZMQEventType 64
    closed          :: ZMQEventType
    closed          = ZMQEventType 128
    closeFailed     :: ZMQEventType
    closeFailed     = ZMQEventType 256
    disconnected    :: ZMQEventType
    disconnected    = ZMQEventType 512
    allEvents       :: ZMQEventType
    allEvents       = ZMQEventType 65535
    monitorStopped  :: ZMQEventType
    monitorStopped  = ZMQEventType 1024

    {-# LINE 182 "src/System/ZMQ4/Internal/Base.hsc" #-}

    -----------------------------------------------------------------------------
    -- Event

    data ZMQEvent = ZMQEvent
      { zeEvent :: {-# UNPACK #-} !ZMQEventType
      , zeValue :: {-# UNPACK #-} !Int32
      }

    {-# LINE 202 "src/System/ZMQ4/Internal/Base.hsc" #-}

    peekZMQEvent :: ZMQMsgPtr -> IO ZMQEvent
    peekZMQEvent :: Ptr ZMQMsg -> IO ZMQEvent
    peekZMQEvent Ptr ZMQMsg
    m = do
        p <- Ptr ZMQMsg -> IO (Ptr ZMQEventType)
    forall a. Ptr ZMQMsg -> IO (Ptr a)
    c_zmq_msg_data Ptr ZMQMsg
    m

    {-# LINE 209 "src/System/ZMQ4/Internal/Base.hsc" #-}
        e <- peek p
        v <- peek (p `plusPtr` 2)
        return (ZMQEvent e v)

    {-# LINE 213 "src/System/ZMQ4/Internal/Base.hsc" #-}

    -----------------------------------------------------------------------------
    -- Security Mechanism

    newtype ZMQSecMechanism = ZMQSecMechanism
      { ZMQSecMechanism -> Int
    secMechanism :: Int
      } deriving (ZMQSecMechanism -> ZMQSecMechanism -> Bool
    (ZMQSecMechanism -> ZMQSecMechanism -> Bool)
    -> (ZMQSecMechanism -> ZMQSecMechanism -> Bool)
    -> Eq ZMQSecMechanism
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ZMQSecMechanism -> ZMQSecMechanism -> Bool
    == :: ZMQSecMechanism -> ZMQSecMechanism -> Bool
    $c/= :: ZMQSecMechanism -> ZMQSecMechanism -> Bool
    /= :: ZMQSecMechanism -> ZMQSecMechanism -> Bool
    Eq, Eq ZMQSecMechanism
    Eq ZMQSecMechanism =>
    (ZMQSecMechanism -> ZMQSecMechanism -> Ordering)
    -> (ZMQSecMechanism -> ZMQSecMechanism -> Bool)
    -> (ZMQSecMechanism -> ZMQSecMechanism -> Bool)
    -> (ZMQSecMechanism -> ZMQSecMechanism -> Bool)
    -> (ZMQSecMechanism -> ZMQSecMechanism -> Bool)
    -> (ZMQSecMechanism -> ZMQSecMechanism -> ZMQSecMechanism)
    -> (ZMQSecMechanism -> ZMQSecMechanism -> ZMQSecMechanism)
    -> Ord ZMQSecMechanism
    ZMQSecMechanism -> ZMQSecMechanism -> Bool
    ZMQSecMechanism -> ZMQSecMechanism -> Ordering
    ZMQSecMechanism -> ZMQSecMechanism -> ZMQSecMechanism
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: ZMQSecMechanism -> ZMQSecMechanism -> Ordering
    compare :: ZMQSecMechanism -> ZMQSecMechanism -> Ordering
    $c< :: ZMQSecMechanism -> ZMQSecMechanism -> Bool
    < :: ZMQSecMechanism -> ZMQSecMechanism -> Bool
    $c<= :: ZMQSecMechanism -> ZMQSecMechanism -> Bool
    <= :: ZMQSecMechanism -> ZMQSecMechanism -> Bool
    $c> :: ZMQSecMechanism -> ZMQSecMechanism -> Bool
    > :: ZMQSecMechanism -> ZMQSecMechanism -> Bool
    $c>= :: ZMQSecMechanism -> ZMQSecMechanism -> Bool
    >= :: ZMQSecMechanism -> ZMQSecMechanism -> Bool
    $cmax :: ZMQSecMechanism -> ZMQSecMechanism -> ZMQSecMechanism
    max :: ZMQSecMechanism -> ZMQSecMechanism -> ZMQSecMechanism
    $cmin :: ZMQSecMechanism -> ZMQSecMechanism -> ZMQSecMechanism
    min :: ZMQSecMechanism -> ZMQSecMechanism -> ZMQSecMechanism
    Ord, Int -> ZMQSecMechanism -> ShowS
    [ZMQSecMechanism] -> ShowS
    ZMQSecMechanism -> String
    (Int -> ZMQSecMechanism -> ShowS)
    -> (ZMQSecMechanism -> String)
    -> ([ZMQSecMechanism] -> ShowS)
    -> Show ZMQSecMechanism
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ZMQSecMechanism -> ShowS
    showsPrec :: Int -> ZMQSecMechanism -> ShowS
    $cshow :: ZMQSecMechanism -> String
    show :: ZMQSecMechanism -> String
    $cshowList :: [ZMQSecMechanism] -> ShowS
    showList :: [ZMQSecMechanism] -> ShowS
    Show)

    secNull   :: ZMQSecMechanism
    secNull :: ZMQSecMechanism
    secNull   = Int -> ZMQSecMechanism
    ZMQSecMechanism Int
    0
    secPlain  :: ZMQSecMechanism
    secPlain :: ZMQSecMechanism
    secPlain  = Int -> ZMQSecMechanism
    ZMQSecMechanism Int
    1
    secCurve  :: ZMQSecMechanism
    secCurve :: ZMQSecMechanism
    secCurve  = Int -> ZMQSecMechanism
    ZMQSecMechanism Int
    2

    {-# LINE 226 "src/System/ZMQ4/Internal/Base.hsc" #-}

    -----------------------------------------------------------------------------
    -- Message Options

    newtype ZMQMsgOption = ZMQMsgOption
      { ZMQMsgOption -> CInt
    msgOptVal :: CInt
      } deriving (ZMQMsgOption -> ZMQMsgOption -> Bool
    (ZMQMsgOption -> ZMQMsgOption -> Bool)
    -> (ZMQMsgOption -> ZMQMsgOption -> Bool) -> Eq ZMQMsgOption
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ZMQMsgOption -> ZMQMsgOption -> Bool
    == :: ZMQMsgOption -> ZMQMsgOption -> Bool
    $c/= :: ZMQMsgOption -> ZMQMsgOption -> Bool
    /= :: ZMQMsgOption -> ZMQMsgOption -> Bool
    Eq, Eq ZMQMsgOption
    Eq ZMQMsgOption =>
    (ZMQMsgOption -> ZMQMsgOption -> Ordering)
    -> (ZMQMsgOption -> ZMQMsgOption -> Bool)
    -> (ZMQMsgOption -> ZMQMsgOption -> Bool)
    -> (ZMQMsgOption -> ZMQMsgOption -> Bool)
    -> (ZMQMsgOption -> ZMQMsgOption -> Bool)
    -> (ZMQMsgOption -> ZMQMsgOption -> ZMQMsgOption)
    -> (ZMQMsgOption -> ZMQMsgOption -> ZMQMsgOption)
    -> Ord ZMQMsgOption
    ZMQMsgOption -> ZMQMsgOption -> Bool
    ZMQMsgOption -> ZMQMsgOption -> Ordering
    ZMQMsgOption -> ZMQMsgOption -> ZMQMsgOption
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: ZMQMsgOption -> ZMQMsgOption -> Ordering
    compare :: ZMQMsgOption -> ZMQMsgOption -> Ordering
    $c< :: ZMQMsgOption -> ZMQMsgOption -> Bool
    < :: ZMQMsgOption -> ZMQMsgOption -> Bool
    $c<= :: ZMQMsgOption -> ZMQMsgOption -> Bool
    <= :: ZMQMsgOption -> ZMQMsgOption -> Bool
    $c> :: ZMQMsgOption -> ZMQMsgOption -> Bool
    > :: ZMQMsgOption -> ZMQMsgOption -> Bool
    $c>= :: ZMQMsgOption -> ZMQMsgOption -> Bool
    >= :: ZMQMsgOption -> ZMQMsgOption -> Bool
    $cmax :: ZMQMsgOption -> ZMQMsgOption -> ZMQMsgOption
    max :: ZMQMsgOption -> ZMQMsgOption -> ZMQMsgOption
    $cmin :: ZMQMsgOption -> ZMQMsgOption -> ZMQMsgOption
    min :: ZMQMsgOption -> ZMQMsgOption -> ZMQMsgOption
    Ord)

    more  :: ZMQMsgOption
    more :: ZMQMsgOption
    more  = CInt -> ZMQMsgOption
    ZMQMsgOption CInt
    1

    {-# LINE 237 "src/System/ZMQ4/Internal/Base.hsc" #-}

    -----------------------------------------------------------------------------
    -- Flags

    newtype ZMQFlag = ZMQFlag
      { ZMQFlag -> CInt
    flagVal :: CInt
      } deriving (ZMQFlag -> ZMQFlag -> Bool
    (ZMQFlag -> ZMQFlag -> Bool)
    -> (ZMQFlag -> ZMQFlag -> Bool) -> Eq ZMQFlag
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ZMQFlag -> ZMQFlag -> Bool
    == :: ZMQFlag -> ZMQFlag -> Bool
    $c/= :: ZMQFlag -> ZMQFlag -> Bool
    /= :: ZMQFlag -> ZMQFlag -> Bool
    Eq, Eq ZMQFlag
    Eq ZMQFlag =>
    (ZMQFlag -> ZMQFlag -> Ordering)
    -> (ZMQFlag -> ZMQFlag -> Bool)
    -> (ZMQFlag -> ZMQFlag -> Bool)
    -> (ZMQFlag -> ZMQFlag -> Bool)
    -> (ZMQFlag -> ZMQFlag -> Bool)
    -> (ZMQFlag -> ZMQFlag -> ZMQFlag)
    -> (ZMQFlag -> ZMQFlag -> ZMQFlag)
    -> Ord ZMQFlag
    ZMQFlag -> ZMQFlag -> Bool
    ZMQFlag -> ZMQFlag -> Ordering
    ZMQFlag -> ZMQFlag -> ZMQFlag
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: ZMQFlag -> ZMQFlag -> Ordering
    compare :: ZMQFlag -> ZMQFlag -> Ordering
    $c< :: ZMQFlag -> ZMQFlag -> Bool
    < :: ZMQFlag -> ZMQFlag -> Bool
    $c<= :: ZMQFlag -> ZMQFlag -> Bool
    <= :: ZMQFlag -> ZMQFlag -> Bool
    $c> :: ZMQFlag -> ZMQFlag -> Bool
    > :: ZMQFlag -> ZMQFlag -> Bool
    $c>= :: ZMQFlag -> ZMQFlag -> Bool
    >= :: ZMQFlag -> ZMQFlag -> Bool
    $cmax :: ZMQFlag -> ZMQFlag -> ZMQFlag
    max :: ZMQFlag -> ZMQFlag -> ZMQFlag
    $cmin :: ZMQFlag -> ZMQFlag -> ZMQFlag
    min :: ZMQFlag -> ZMQFlag -> ZMQFlag
    Ord)

    dontWait  :: ZMQFlag
    dontWait :: ZMQFlag
    dontWait  = CInt -> ZMQFlag
    ZMQFlag CInt
    1
    sndMore   :: ZMQFlag
    sndMore :: ZMQFlag
    sndMore   = CInt -> ZMQFlag
    ZMQFlag CInt
    2

    {-# LINE 249 "src/System/ZMQ4/Internal/Base.hsc" #-}

    -----------------------------------------------------------------------------
    -- Poll Events

    newtype ZMQPollEvent = ZMQPollEvent
      { ZMQPollEvent -> CShort
    pollVal :: CShort
      } deriving (ZMQPollEvent -> ZMQPollEvent -> Bool
    (ZMQPollEvent -> ZMQPollEvent -> Bool)
    -> (ZMQPollEvent -> ZMQPollEvent -> Bool) -> Eq ZMQPollEvent
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ZMQPollEvent -> ZMQPollEvent -> Bool
    == :: ZMQPollEvent -> ZMQPollEvent -> Bool
    $c/= :: ZMQPollEvent -> ZMQPollEvent -> Bool
    /= :: ZMQPollEvent -> ZMQPollEvent -> Bool
    Eq, Eq ZMQPollEvent
    Eq ZMQPollEvent =>
    (ZMQPollEvent -> ZMQPollEvent -> Ordering)
    -> (ZMQPollEvent -> ZMQPollEvent -> Bool)
    -> (ZMQPollEvent -> ZMQPollEvent -> Bool)
    -> (ZMQPollEvent -> ZMQPollEvent -> Bool)
    -> (ZMQPollEvent -> ZMQPollEvent -> Bool)
    -> (ZMQPollEvent -> ZMQPollEvent -> ZMQPollEvent)
    -> (ZMQPollEvent -> ZMQPollEvent -> ZMQPollEvent)
    -> Ord ZMQPollEvent
    ZMQPollEvent -> ZMQPollEvent -> Bool
    ZMQPollEvent -> ZMQPollEvent -> Ordering
    ZMQPollEvent -> ZMQPollEvent -> ZMQPollEvent
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: ZMQPollEvent -> ZMQPollEvent -> Ordering
    compare :: ZMQPollEvent -> ZMQPollEvent -> Ordering
    $c< :: ZMQPollEvent -> ZMQPollEvent -> Bool
    < :: ZMQPollEvent -> ZMQPollEvent -> Bool
    $c<= :: ZMQPollEvent -> ZMQPollEvent -> Bool
    <= :: ZMQPollEvent -> ZMQPollEvent -> Bool
    $c> :: ZMQPollEvent -> ZMQPollEvent -> Bool
    > :: ZMQPollEvent -> ZMQPollEvent -> Bool
    $c>= :: ZMQPollEvent -> ZMQPollEvent -> Bool
    >= :: ZMQPollEvent -> ZMQPollEvent -> Bool
    $cmax :: ZMQPollEvent -> ZMQPollEvent -> ZMQPollEvent
    max :: ZMQPollEvent -> ZMQPollEvent -> ZMQPollEvent
    $cmin :: ZMQPollEvent -> ZMQPollEvent -> ZMQPollEvent
    min :: ZMQPollEvent -> ZMQPollEvent -> ZMQPollEvent
    Ord)

    pollIn     :: ZMQPollEvent
    pollIn :: ZMQPollEvent
    pollIn     = CShort -> ZMQPollEvent
    ZMQPollEvent CShort
    1
    pollOut    :: ZMQPollEvent
    pollOut :: ZMQPollEvent
    pollOut    = CShort -> ZMQPollEvent
    ZMQPollEvent CShort
    2
    pollerr    :: ZMQPollEvent
    pollerr :: ZMQPollEvent
    pollerr    = CShort -> ZMQPollEvent
    ZMQPollEvent CShort
    4

    {-# LINE 262 "src/System/ZMQ4/Internal/Base.hsc" #-}

    -----------------------------------------------------------------------------
    -- function declarations

    -- general initialization

    foreign import ccall unsafe "zmq.h zmq_version"
        c_zmq_version :: Ptr CInt -> Ptr CInt -> Ptr CInt -> IO ()

    foreign import ccall unsafe "zmq.h zmq_ctx_new"
        c_zmq_ctx_new :: IO ZMQCtx

    foreign import ccall unsafe "zmq.h zmq_ctx_shutdown"
        c_zmq_ctx_shutdown :: ZMQCtx -> IO CInt

    foreign import ccall safe "zmq.h zmq_ctx_term"
        c_zmq_ctx_term :: ZMQCtx -> IO CInt

    foreign import ccall unsafe "zmq.h zmq_ctx_get"
        c_zmq_ctx_get :: ZMQCtx -> CInt -> IO CInt

    foreign import ccall unsafe "zmq.h zmq_ctx_set"
        c_zmq_ctx_set :: ZMQCtx -> CInt -> CInt -> IO CInt

    -- zmq_msg_t related

    foreign import ccall unsafe "zmq.h zmq_msg_init"
        c_zmq_msg_init :: ZMQMsgPtr -> IO CInt

    foreign import ccall unsafe "zmq.h zmq_msg_init_size"
        c_zmq_msg_init_size :: ZMQMsgPtr -> CSize -> IO CInt

    foreign import ccall unsafe "zmq.h zmq_msg_close"
        c_zmq_msg_close :: ZMQMsgPtr -> IO CInt

    foreign import ccall unsafe "zmq.h zmq_msg_data"
        c_zmq_msg_data :: ZMQMsgPtr -> IO (Ptr a)

    foreign import ccall unsafe "zmq.h zmq_msg_size"
        c_zmq_msg_size :: ZMQMsgPtr -> IO CSize

    foreign import ccall unsafe "zmq.h zmq_msg_get"
        c_zmq_msg_get :: ZMQMsgPtr -> CInt -> IO CInt

    foreign import ccall unsafe "zmq.h zmq_msg_set"
        c_zmq_msg_set :: ZMQMsgPtr -> CInt -> CInt -> IO CInt

    -- socket

    foreign import ccall unsafe "zmq.h zmq_socket"
        c_zmq_socket :: ZMQCtx -> CInt -> IO ZMQSocket

    foreign import ccall unsafe "zmq.h zmq_close"
        c_zmq_close :: ZMQSocket -> IO CInt

    foreign import ccall unsafe "zmq.h zmq_setsockopt"
        c_zmq_setsockopt :: ZMQSocket
                         -> CInt   -- option
                         -> Ptr () -- option value
                         -> CSize  -- option value size
                         -> IO CInt

    foreign import ccall unsafe "zmq.h zmq_getsockopt"
        c_zmq_getsockopt :: ZMQSocket
                         -> CInt       -- option
                         -> Ptr ()     -- option value
                         -> Ptr CSize  -- option value size ptr
                         -> IO CInt

    foreign import ccall unsafe "zmq.h zmq_bind"
        c_zmq_bind :: ZMQSocket -> CString -> IO CInt

    foreign import ccall unsafe "zmq.h zmq_unbind"
        c_zmq_unbind :: ZMQSocket -> CString -> IO CInt

    foreign import ccall unsafe "zmq.h zmq_connect"
        c_zmq_connect :: ZMQSocket -> CString -> IO CInt

    foreign import ccall unsafe "zmq.h zmq_disconnect"
        c_zmq_disconnect :: ZMQSocket -> CString -> IO CInt

    {-# LINE 350 "src/System/ZMQ4/Internal/Base.hsc" #-}
    foreign import ccall unsafe "zmq.h zmq_sendmsg"
        c_zmq_sendmsg :: ZMQSocket -> ZMQMsgPtr -> CInt -> IO CInt

    foreign import ccall unsafe "zmq.h zmq_recvmsg"
        c_zmq_recvmsg :: ZMQSocket -> ZMQMsgPtr -> CInt -> IO CInt

    {-# LINE 356 "src/System/ZMQ4/Internal/Base.hsc" #-}

    foreign import ccall unsafe "zmq.h zmq_socket_monitor"
        c_zmq_socket_monitor :: ZMQSocket -> CString -> CInt -> IO CInt

    -- errors

    foreign import ccall unsafe "zmq.h zmq_errno"
        c_zmq_errno :: IO CInt

    foreign import ccall unsafe "zmq.h zmq_strerror"
        c_zmq_strerror :: CInt -> IO CString

    -- proxy

    foreign import ccall safe "zmq.h zmq_proxy"
        c_zmq_proxy :: ZMQSocket -> ZMQSocket -> ZMQSocket -> IO CInt

    -- poll

    foreign import ccall safe "zmq.h zmq_poll"
        c_zmq_poll :: ZMQPollPtr -> CInt -> CLong -> IO CInt

    -- Z85 encode/decode

    foreign import ccall unsafe "zmq.h zmq_z85_encode"
        c_zmq_z85_encode :: CString -> Ptr Word8 -> CSize -> IO CString

    foreign import ccall unsafe "zmq.h zmq_z85_decode"
        c_zmq_z85_decode :: Ptr Word8 -> CString -> IO (Ptr Word8)

    -- curve crypto

    foreign import ccall unsafe "zmq.h zmq_curve_keypair"
        c_zmq_curve_keypair :: CString -> CString -> IO CInt