irc-fun-messages-0.4: Types and functions for working with the IRC protocol.

Safe HaskellNone
LanguageHaskell2010

Network.Irc.Messages

Contents

Description

This module handles parsing and serializing IRC messages and replies. Types and other functionality are provided in the submodules.

Synopsis

Parsing

parseMessage :: Text -> Maybe GenericMessage Source #

Parse a raw IRC message string into a generic message structure.

messageIsReply :: GenericMessage -> Bool Source #

Check is a given message is a server reply, i.e. has a numeric command and the sender is a server.

messageToReply :: GenericMessage -> Either Text GenericReply Source #

Try to convert a generic message into a matching reply value. If successful, return Right the reply. If the message isn't a reply, return Left an error message.

parse :: Text -> Maybe (Either GenericReply GenericMessage) Source #

Parse a raw IRC message string into a generic message structure. If the message is detected to be a server reply, a generic reply structure is returned.

This is essentially a combination of parseMessage and messageToReply.

analyzeMessage :: GenericMessage -> Either Text (Either GenericReply SpecificMessage) Source #

Read a generic message structure into specific message details. Return Left an error description if analysis fails. If the message is detected to be a reply, return a generic reply structure without analyzing.

analyzeReply :: GenericReply -> Either Text SpecificReply Source #

Read a generic reply structure into specific reply details. Return Left an error description if analysis fails.

analyze :: GenericMessage -> Either Text (Either SpecificReply SpecificMessage) Source #

Read a generic reply structure into specific message or reply details. Return Left an error description if analysis fails.

This is essentially a combination or analyzeMessage and analyzeReply.

Serializing

buildMessage :: SpecificMessage -> GenericMessage Source #

Fill a generic message record using a specific message's details.

buildReply :: SpecificReply -> GenericReply Source #

Fill a generic reply record using a specific reply's details.

messageFromReply :: GenericReply -> GenericMessage Source #

Convert a reply, which is a message with a numeric command name, into a generic message value.

serializeMessage :: GenericMessage -> Text Source #

Write a message into an IRC protocol message formatted string.

serializeReply :: GenericReply -> Text Source #

Write a reply into an IRC protocol message formatted string.

This is essentially a combination of messageFromReply and serializeMessage.