glirc-2.41: Console IRC client
Copyright(c) Dan Doel 2016
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellSafe-Inferred
LanguageHaskell2010

Client.Commands.Recognizer

Description

This module implements a trie for recognizing valid commands. This allows entered strings to be classified as either a valid command (with an associated value), the prefix of a valid command, or invalid.

Synopsis

Documentation

data Recognizer a Source #

A map from Text values to a values that is capable of yielding more detailed information when looking up keys that are not actually in the map.

Instances

Instances details
Foldable Recognizer Source # 
Instance details

Defined in Client.Commands.Recognizer

Methods

fold :: Monoid m => Recognizer m -> m #

foldMap :: Monoid m => (a -> m) -> Recognizer a -> m #

foldMap' :: Monoid m => (a -> m) -> Recognizer a -> m #

foldr :: (a -> b -> b) -> b -> Recognizer a -> b #

foldr' :: (a -> b -> b) -> b -> Recognizer a -> b #

foldl :: (b -> a -> b) -> b -> Recognizer a -> b #

foldl' :: (b -> a -> b) -> b -> Recognizer a -> b #

foldr1 :: (a -> a -> a) -> Recognizer a -> a #

foldl1 :: (a -> a -> a) -> Recognizer a -> a #

toList :: Recognizer a -> [a] #

null :: Recognizer a -> Bool #

length :: Recognizer a -> Int #

elem :: Eq a => a -> Recognizer a -> Bool #

maximum :: Ord a => Recognizer a -> a #

minimum :: Ord a => Recognizer a -> a #

sum :: Num a => Recognizer a -> a #

product :: Num a => Recognizer a -> a #

Functor Recognizer Source # 
Instance details

Defined in Client.Commands.Recognizer

Methods

fmap :: (a -> b) -> Recognizer a -> Recognizer b #

(<$) :: a -> Recognizer b -> Recognizer a #

Monoid (Recognizer a) Source # 
Instance details

Defined in Client.Commands.Recognizer

Semigroup (Recognizer a) Source # 
Instance details

Defined in Client.Commands.Recognizer

Show a => Show (Recognizer a) Source # 
Instance details

Defined in Client.Commands.Recognizer

recognize :: Text -> Recognizer a -> Recognition a Source #

Attempt to recognize a string, yielding a Recognition result.

data Recognition a Source #

Possible results of recognizing text.

Constructors

Exact a

text matched exactly, yielding the given value

Prefix [Text]

text would be recognized if joined to the given suffixes

Invalid

text could not possibly be recognized

Instances

Instances details
Functor Recognition Source # 
Instance details

Defined in Client.Commands.Recognizer

Methods

fmap :: (a -> b) -> Recognition a -> Recognition b #

(<$) :: a -> Recognition b -> Recognition a #

Show a => Show (Recognition a) Source # 
Instance details

Defined in Client.Commands.Recognizer

fromCommands :: [(Text, a)] -> Recognizer a Source #

Create a Recognizer from an association list. If a key appears twice, the earliest associated value will be used.

addCommand :: Text -> a -> Recognizer a -> Recognizer a Source #

Add a key-value pair to a Recognizer. This will override the value already present if one exists.

keys :: Recognizer a -> [Text] Source #

Compute all strings that will be recognized by a Recognizer.