glirc- Console IRC client

Copyright(c) Dan Doel, 2016
Safe HaskellSafe



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.



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.

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.


Exact a

text matched exactly, yielding the given value

Prefix [Text]

text would be recognized if joined to the given suffixes


text could not possibly be recognized


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.