pontarius-xmpp-0.5.2: An XMPP client library

Safe HaskellNone
LanguageHaskell98

Network.Xmpp.Lens

Contents

Description

(More than just) Van Laarhoven lenses for XMPP types. The accessors in here are designed to work with an optics library like lens or lens-family. This module also provides a few simple functions (view, modify, set and getAll) so you don't need to pull in another library to get some use out of them.

  • The name of the lenses corresponds to the field name of the data types with an upper-case L appended. For documentation of the fields refer to the documentation of the data types (linked in the section header)
  • Same goes for Traversals, except they are suffixed with a 'T'
  • Prism generally start with an underscore

NB you do not need to import this module to get access to the optics defined herein. They are also exported from Network.Xmpp. You only need to import this module if you want to use the complementary accessor functions without using an optics library like lens or lens-family

Synopsis

Documentation

type Lens a b = forall f. Functor f => (b -> f b) -> a -> f a Source #

Deprecated: Use Lens' from lens-family or lens

Van-Laarhoven lenses.

type Traversal a b = forall f. Applicative f => (b -> f b) -> a -> f a Source #

Deprecated: Use Traversal' from lens-family or lens

type Prism a b = forall p f. (Choice p, Applicative f) => p b (f b) -> p a (f a) Source #

type Iso a b = forall p f. (Profunctor p, Functor f) => p b (f b) -> p a (f a) Source #

Accessors

Reimplementation of the basic lens functions so you don't have to bring in a lens library to use the optics

Lenses

view :: FoldLike b a a' b b' -> a -> b #

view :: Getter a a' b b' -> a -> b

Demote a lens or getter to a projection function.

view :: Monoid b => Fold a a' b b' -> a -> b

Returns the monoidal summary of a traversal or a fold.

modify :: Traversal a b -> (b -> b) -> a -> a Source #

Deprecated: use over (lens-family, lens)

set :: Setter a a' b b' -> b' -> a -> a' #

Set all referenced fields to the given value.

Traversals

getAll :: Traversal a b -> a -> [b] Source #

Deprecated: use toListOf (lens-family), partsOf (lens) or similar

Return all the values a Traversal is pointing to in a list

Prisms

Construction

prism' :: (b -> s) -> (s -> Maybe b) -> Prism s b Source #

mkLens :: (a -> b) -> (b -> a -> a) -> Lens a b Source #

mkIso :: (a -> b) -> (b -> a) -> Iso a b Source #

Lenses

JID

Stanzas and Nonzas

class IsStanza s where Source #

Minimal complete definition

from, to, lang, sid, payloadT

Methods

from :: Lens s (Maybe Jid) Source #

From-attribute of the stanza

to :: Lens s (Maybe Jid) Source #

To-attribute of the stanza

lang :: Lens s (Maybe LangTag) Source #

Langtag of the stanza

sid :: Lens s (Maybe Text) Source #

Stanza ID. Setting this to Nothing for IQ* stanzas will set the id to the empty Text.

payloadT :: Traversal s Element Source #

Traversal over the payload elements.

Instances

IsStanza PresenceError Source # 
IsStanza Presence Source # 
IsStanza MessageError Source # 
IsStanza Message Source # 
IsStanza IQError Source # 
IsStanza IQResult Source # 
IsStanza IQRequest Source # 
IsStanza Stanza Source # 

class HasStanzaPayload s p | s -> p where Source #

Minimal complete definition

payload

Methods

payload :: Lens s p Source #

Payload element(s) of the stanza. Since the amount of elements possible in a stanza vary by type, this lens can't be used with a general Stanza. There is, however, a more general Traversable that works with all stanzas (including Stanza): payloadT

StanzaError

Stream

Stream Features

StreamConfiguration

TLS parameters

tlsServerIdentificationL :: Lens SessionConfiguration (String, ByteString) Source #

Access clientServerIdentification inside tlsParams inside streamConfiguration

tlsSupportedCiphersL :: Lens SessionConfiguration [Cipher] Source #

Access supportedCiphers inside clientSupported inside tlsParams

tlsSupportedVersionsL :: Lens SessionConfiguration [Version] Source #

Access supportedVersions inside clientSupported inside tlsParams

tlsUseNameIndicationL :: Lens SessionConfiguration Bool Source #

Access clientUseServerNameIndication inside tlsParams

SessionConfiguration

IM

Roster

Roster

Item

QueryItem

Query

IM Message

MessageBody

MessageThread

MessageSubject

InstantMessage

IMPresence