mqtt-hs-1.0.2: A MQTT client library.

CopyrightLukas Braun 2014-2016
LicenseGPL-3
Maintainerkoomi+mqtt@hackerspace-bamberg.de
Safe HaskellNone
LanguageHaskell2010

Network.MQTT.Types

Contents

Description

Types representing MQTT messages.

Synopsis

Messages

data Message (t :: MsgType) Source #

A MQTT message, indexed by the type of the message (MsgType).

Constructors

Message 

data SomeMessage where Source #

Any message, hiding the index.

Constructors

SomeMessage :: SingI t => Message t -> SomeMessage 

data MqttHeader Source #

Fixed header required in every message.

Constructors

Header 

Fields

  • dup :: Bool

    Has this message been sent before?

  • qos :: QoS

    Quality of Service-level

  • retain :: Bool

    Should the broker retain the message for future subscribers?

setDup :: Message t -> Message t Source #

Set the dup flag to True.

Message body

data MessageBody (t :: MsgType) where Source #

The body of a MQTT message, indexed by the type of the message (MsgType).

Constructors

Connect :: {..} -> MessageBody CONNECT 

Fields

ConnAck :: {..} -> MessageBody CONNACK 

Fields

Publish :: {..} -> MessageBody PUBLISH 

Fields

PubAck :: {..} -> MessageBody PUBACK 

Fields

PubRec :: {..} -> MessageBody PUBREC 

Fields

PubRel :: {..} -> MessageBody PUBREL 

Fields

PubComp :: {..} -> MessageBody PUBCOMP 

Fields

Subscribe :: {..} -> MessageBody SUBSCRIBE 

Fields

SubAck :: {..} -> MessageBody SUBACK 

Fields

Unsubscribe :: {..} -> MessageBody UNSUBSCRIBE 

Fields

UnsubAck :: {..} -> MessageBody UNSUBACK 

Fields

PingReq :: MessageBody PINGREQ 
PingResp :: MessageBody PINGRESP 
Disconnect :: MessageBody DISCONNECT 

Miscellaneous

data Will Source #

A Will message is published by the broker if a client disconnects without sending a DISCONNECT.

Constructors

Will 

Fields

Instances
Eq Will Source # 
Instance details

Defined in Network.MQTT.Types

Methods

(==) :: Will -> Will -> Bool #

(/=) :: Will -> Will -> Bool #

Show Will Source # 
Instance details

Defined in Network.MQTT.Types

Methods

showsPrec :: Int -> Will -> ShowS #

show :: Will -> String #

showList :: [Will] -> ShowS #

data QoS Source #

The different levels of QoS

Constructors

NoConfirm

Fire and forget, message will be published at most once.

Confirm

Acknowledged delivery, message will be published at least once.

Handshake

Assured delivery, message will be published exactly once.

Instances
Enum QoS Source # 
Instance details

Defined in Network.MQTT.Types

Methods

succ :: QoS -> QoS #

pred :: QoS -> QoS #

toEnum :: Int -> QoS #

fromEnum :: QoS -> Int #

enumFrom :: QoS -> [QoS] #

enumFromThen :: QoS -> QoS -> [QoS] #

enumFromTo :: QoS -> QoS -> [QoS] #

enumFromThenTo :: QoS -> QoS -> QoS -> [QoS] #

Eq QoS Source # 
Instance details

Defined in Network.MQTT.Types

Methods

(==) :: QoS -> QoS -> Bool #

(/=) :: QoS -> QoS -> Bool #

Ord QoS Source # 
Instance details

Defined in Network.MQTT.Types

Methods

compare :: QoS -> QoS -> Ordering #

(<) :: QoS -> QoS -> Bool #

(<=) :: QoS -> QoS -> Bool #

(>) :: QoS -> QoS -> Bool #

(>=) :: QoS -> QoS -> Bool #

max :: QoS -> QoS -> QoS #

min :: QoS -> QoS -> QoS #

Show QoS Source # 
Instance details

Defined in Network.MQTT.Types

Methods

showsPrec :: Int -> QoS -> ShowS #

show :: QoS -> String #

showList :: [QoS] -> ShowS #

getMsgID :: MessageBody t -> Maybe MsgID Source #

Get the message ID of any message, if it exists.

data Topic Source #

A topic is a "hierarchical name space that defines a taxonomy of information sources for which subscribers can register an interest." See the specification for more details.

A topic can be inspected by using the matches function or after using getLevels, e.g.:

f1 topic
  | topic `matches` "mqtt/hs/example" = putStrLn "example"
  | topic `matches` "mqtt/hs/#" = putStrLn "wildcard"

f2 topic = case getLevels topic of
             ["mqtt", "hs", "example"] -> putStrLn "example"
             "mqtt" : "hs" : _ -> putStrLn "wildcard"
Instances
Eq Topic Source # 
Instance details

Defined in Network.MQTT.Types

Methods

(==) :: Topic -> Topic -> Bool #

(/=) :: Topic -> Topic -> Bool #

Show Topic Source # 
Instance details

Defined in Network.MQTT.Types

Methods

showsPrec :: Int -> Topic -> ShowS #

show :: Topic -> String #

showList :: [Topic] -> ShowS #

IsString Topic Source # 
Instance details

Defined in Network.MQTT.Types

Methods

fromString :: String -> Topic #

matches :: Topic -> Topic -> Bool Source #

Check if one of the Topics matches the other, taking wildcards into consideration.

getLevels :: Topic -> [Text] Source #

Split a topic into its individual levels.

fromLevels :: [Text] -> Topic Source #

Create a Topic from its individual levels.

newtype MqttText Source #

MQTT uses length-prefixed UTF-8 as text encoding.

Constructors

MqttText 

Fields

Instances
Eq MqttText Source # 
Instance details

Defined in Network.MQTT.Types

Show MqttText Source # 
Instance details

Defined in Network.MQTT.Types

IsString MqttText Source # 
Instance details

Defined in Network.MQTT.Types

toConnectError :: Word8 -> ConnectError Source #

Convert a return code to a ConnectError.

Message types

data MsgType Source #

The various types of messages.

Instances
Enum MsgType Source # 
Instance details

Defined in Network.MQTT.Types

Eq MsgType Source # 
Instance details

Defined in Network.MQTT.Types

Methods

(==) :: MsgType -> MsgType -> Bool #

(/=) :: MsgType -> MsgType -> Bool #

Ord MsgType Source # 
Instance details

Defined in Network.MQTT.Types

Show MsgType Source # 
Instance details

Defined in Network.MQTT.Types

SDecide MsgType Source # 
Instance details

Defined in Network.MQTT.Types

Methods

(%~) :: Sing a -> Sing b -> Decision (a :~: b) #

SingKind MsgType Source # 
Instance details

Defined in Network.MQTT.Types

Associated Types

type Demote MsgType = (r :: *) #

SingI CONNECT Source # 
Instance details

Defined in Network.MQTT.Types

Methods

sing :: Sing CONNECT #

SingI CONNACK Source # 
Instance details

Defined in Network.MQTT.Types

Methods

sing :: Sing CONNACK #

SingI PUBLISH Source # 
Instance details

Defined in Network.MQTT.Types

Methods

sing :: Sing PUBLISH #

SingI PUBACK Source # 
Instance details

Defined in Network.MQTT.Types

Methods

sing :: Sing PUBACK #

SingI PUBREC Source # 
Instance details

Defined in Network.MQTT.Types

Methods

sing :: Sing PUBREC #

SingI PUBREL Source # 
Instance details

Defined in Network.MQTT.Types

Methods

sing :: Sing PUBREL #

SingI PUBCOMP Source # 
Instance details

Defined in Network.MQTT.Types

Methods

sing :: Sing PUBCOMP #

SingI SUBSCRIBE Source # 
Instance details

Defined in Network.MQTT.Types

Methods

sing :: Sing SUBSCRIBE #

SingI SUBACK Source # 
Instance details

Defined in Network.MQTT.Types

Methods

sing :: Sing SUBACK #

SingI UNSUBSCRIBE Source # 
Instance details

Defined in Network.MQTT.Types

SingI UNSUBACK Source # 
Instance details

Defined in Network.MQTT.Types

Methods

sing :: Sing UNSUBACK #

SingI PINGREQ Source # 
Instance details

Defined in Network.MQTT.Types

Methods

sing :: Sing PINGREQ #

SingI PINGRESP Source # 
Instance details

Defined in Network.MQTT.Types

Methods

sing :: Sing PINGRESP #

SingI DISCONNECT Source # 
Instance details

Defined in Network.MQTT.Types

Methods

sing :: Sing DISCONNECT #

data Sing (z :: MsgType) Source # 
Instance details

Defined in Network.MQTT.Types

type Demote MsgType Source # 
Instance details

Defined in Network.MQTT.Types

toMsgType :: SingI t => Message t -> MsgType Source #

Determine the MsgType of a Message.

Singletons

Singletons are used to build a bridge between the type and value level. See the singletons package for more information.

You do not have to use or understand these in order to use this library, they are mostly used internally to get better guarantees about the flow of Messages.

toSMsgType :: SingI t => Message t -> SMsgType t Source #

Determine the singleton SMsgType of a Message.

type SMsgType = (Sing :: MsgType -> Type) Source #

withSomeSingI :: MsgType -> (forall t. SingI t => SMsgType t -> r) -> r Source #

Helper to generate both an implicit and explicit singleton.

data family Sing (a :: k) :: * #

The singleton kind-indexed data family.

Instances
data Sing (z :: Bool) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (z :: Bool) where
data Sing (z :: Ordering) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (z :: Ordering) where
data Sing (n :: Nat) 
Instance details

Defined in Data.Singletons.TypeLits.Internal

data Sing (n :: Nat) where
data Sing (n :: Symbol) 
Instance details

Defined in Data.Singletons.TypeLits.Internal

data Sing (n :: Symbol) where
data Sing (z :: ()) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (z :: ()) where
data Sing (z :: Void) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (z :: Void)
data Sing (z :: MsgType) # 
Instance details

Defined in Network.MQTT.Types

data Sing (z :: [a]) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (z :: [a]) where
data Sing (z :: Maybe a) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (z :: Maybe a) where
data Sing (z :: NonEmpty a) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (z :: NonEmpty a) where
data Sing (z :: Either a b) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (z :: Either a b) where
data Sing (z :: (a, b)) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (z :: (a, b)) where
data Sing (f :: k1 ~> k2) 
Instance details

Defined in Data.Singletons.Internal

data Sing (f :: k1 ~> k2) = SLambda {}
data Sing (z :: (a, b, c)) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (z :: (a, b, c)) where
data Sing (z :: (a, b, c, d)) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (z :: (a, b, c, d)) where
data Sing (z :: (a, b, c, d, e)) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (z :: (a, b, c, d, e)) where
data Sing (z :: (a, b, c, d, e, f)) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (z :: (a, b, c, d, e, f)) where
data Sing (z :: (a, b, c, d, e, f, g)) 
Instance details

Defined in Data.Singletons.Prelude.Instances

data Sing (z :: (a, b, c, d, e, f, g)) where