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

Safe HaskellSafe-Inferred
LanguageHaskell2010

Network.IRC.Fun.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 :: String -> 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 String 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 :: String -> 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 String (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 String SpecificReply Source

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

analyze :: GenericMessage -> Either String (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 -> String Source

Write a message into an IRC protocol message formatted string.

serializeReply :: GenericReply -> String Source

Write a reply into an IRC protocol message formatted string.

This is essentially a combination of messageFromReply and serializeMessage.