vty-5.15.1: A simple terminal UI library

Safe Haskell | Safe
Language | Haskell2010

Graphics.Vty.Input.Classify.Parse

Description

This module provides a simple parser for parsing input event control sequences.

Synopsis

- type Parser a = MaybeT (State String) a
- runParser :: String -> Parser Event -> KClass
- failParse :: Parser a
- readInt :: Parser Int
- readChar :: Parser Char
- expectChar :: Char -> Parser ()

# Documentation

type Parser a = MaybeT (State String) a #

runParser :: String -> Parser Event -> KClass #

Run a parser on a given input string. If the parser fails, return `Invalid`. Otherwise return the valid event (`Valid`) and the remaining unparsed characters.

failParse :: Parser a #

Fail a parsing operation.

readInt :: Parser Int #

Read an integer from the input stream. If an integer cannot be read, fail parsing. E.g. calling readInt on an input of "123abc" will return '123' and consume those characters.

readChar :: Parser Char #

Read a character from the input stream. If one cannot be read (e.g. we are out of characters), fail parsing.

expectChar :: Char -> Parser () #

Read a character from the input stream and fail parsing if it is not the specified character.