owenbot-0.1.0.0
LicenseBSD (see the LICENSE file)
Safe HaskellNone
LanguageHaskell2010

Command.Parser

Description

Parser component for Commands. Its usage is mainly internal, to be used from Command.Command.

If you want to add your own parser argument type, you can either add it here (to be reused across multiple modules), or in your receive module (if it is only used there). Either works really, but sometimes you need the other to prevent looping imports.

Synopsis

Documentation

class ParsableArgument a where Source #

A ParsableArgument is a dataclass that represents arguments that can be parsed from a message text. Any datatype that is an instance of this dataclass can be used as function arguments for a command handler in command.

Methods

parserForArg :: Parser a Source #

parserForArg is a parser that returns the parsed element.

Instances

Instances details
ParsableArgument String Source #

Any number of non-space characters. If quoted, spaces are allowed. Quotes in quoted phrases can be escaped with a backslash. The following is parsed as a single string: "He said, \"Lovely\"."

Instance details

Defined in Command.Parser

ParsableArgument Text Source #

Wrapper for the String version, since Text is the trend nowadays. Both are provided so that it can easily be used for arguments in other functions that only accept one of the types.

Instance details

Defined in Command.Parser

ParsableArgument ActivityType Source #

Parses "playing", "streaming", "listening to" and "competing in" as ActivityTypes.

Instance details

Defined in Command.Parser

ParsableArgument UpdateStatusType Source #

Parses "online" "dnd" "idle" and "invisible" as UpdateStatusTypes

Instance details

Defined in Command.Parser

ParsableArgument Snowflake Source # 
Instance details

Defined in Command.Parser

ParsableArgument RemainingText Source #

The rest of the arguments. Spaces and quotes are preserved as-is, unlike with Text. At least one character is required.

Instance details

Defined in Command.Parser

ParsableArgument [Text] Source #

Zero or more texts. Each one could be quoted or not.

Instance details

Defined in Command.Parser

ParsableArgument a => ParsableArgument (Maybe a) Source #

An argument that can or cannot exist.

Instance details

Defined in Command.Parser

(ParsableArgument a, ParsableArgument b) => ParsableArgument (a, b) Source #

An argument that always has to be followed by another.

Instance details

Defined in Command.Parser

Methods

parserForArg :: Parser (a, b) Source #

newtype RemainingText Source #

Datatype wrapper for the remaining text in the input. Handy for capturing everything remaining. The accessor function getDeez isn't really meant to be used since pattern matching can do everything. Open to renaming.

Example usage:

setStatus =
    command "status"
    $ \msg newStatus newType (Remaining newName) -> do
        ...

Constructors

Remaining 

Fields

Instances

Instances details
ParsableArgument RemainingText Source #

The rest of the arguments. Spaces and quotes are preserved as-is, unlike with Text. At least one character is required.

Instance details

Defined in Command.Parser

manyTill1 :: Stream s m t => ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a] Source #

manyTill1 p end is a parser that applies parser p one or more times until parser end succeeds. This is a variation on manyTill from Parsec.

endOrSpaces :: Parser () Source #

eofOrSpaces is a parser that parses an end of command, or at least one space and skips the result.