| ||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||
Description | ||||||||||||||||||||||||||||||||||||||||
The Read class and instances for basic data types. | ||||||||||||||||||||||||||||||||||||||||
Synopsis | ||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||
Documentation | ||||||||||||||||||||||||||||||||||||||||
class Read a where | ||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||
type ReadS a = String -> [(a, String)] | ||||||||||||||||||||||||||||||||||||||||
A parser for a type a, represented as a function that takes a String and returns a list of possible parses as (a,String) pairs. Note that this kind of backtracking parser is very inefficient; reading a large structure may be quite slow (cf ReadP). | ||||||||||||||||||||||||||||||||||||||||
reads :: Read a => ReadS a | ||||||||||||||||||||||||||||||||||||||||
equivalent to readsPrec with a precedence of 0. | ||||||||||||||||||||||||||||||||||||||||
readp :: Read a => ReadP a | ||||||||||||||||||||||||||||||||||||||||
readEither :: Read a => String -> Either String a | ||||||||||||||||||||||||||||||||||||||||
read :: Read a => String -> a | ||||||||||||||||||||||||||||||||||||||||
The read function reads input from a string, which must be completely consumed by the input process. | ||||||||||||||||||||||||||||||||||||||||
lex :: ReadS String | ||||||||||||||||||||||||||||||||||||||||
The lex function reads a single lexeme from the input, discarding initial white space, and returning the characters that constitute the lexeme. If the input string contains only white space, lex returns a single successful `lexeme' consisting of the empty string. (Thus lex "" = [("","")].) If there is no legal lexeme at the beginning of the input string, lex fails (i.e. returns []). This lexer is not completely faithful to the Haskell lexical syntax in the following respects:
| ||||||||||||||||||||||||||||||||||||||||
lexLitChar :: ReadS String | ||||||||||||||||||||||||||||||||||||||||
Read a string representation of a character, using Haskell source-language escape conventions. For example: lexLitChar "\\nHello" = [("\\n", "Hello")] | ||||||||||||||||||||||||||||||||||||||||
readLitChar :: ReadS Char | ||||||||||||||||||||||||||||||||||||||||
Read a string representation of a character, using Haskell source-language escape conventions, and convert it to the character that it encodes. For example: readLitChar "\\nHello" = [('\n', "Hello")] | ||||||||||||||||||||||||||||||||||||||||
lexDigits :: ReadS String | ||||||||||||||||||||||||||||||||||||||||
Reads a non-empty string of decimal digits. | ||||||||||||||||||||||||||||||||||||||||
lexP :: ReadPrec Lexeme | ||||||||||||||||||||||||||||||||||||||||
Parse a single lexeme | ||||||||||||||||||||||||||||||||||||||||
paren :: ReadPrec a -> ReadPrec a | ||||||||||||||||||||||||||||||||||||||||
(paren p) parses "(P0)" where p parses "P0" in precedence context zero | ||||||||||||||||||||||||||||||||||||||||
parens :: ReadPrec a -> ReadPrec a | ||||||||||||||||||||||||||||||||||||||||
(parens p) parses "P", "(P0)", "((P0))", etc, where p parses "P" in the current precedence context and parses "P0" in precedence context zero | ||||||||||||||||||||||||||||||||||||||||
list :: ReadPrec a -> ReadPrec [a] | ||||||||||||||||||||||||||||||||||||||||
(list p) parses a list of things parsed by p, using the usual square-bracket syntax. | ||||||||||||||||||||||||||||||||||||||||
choose :: [(String, ReadPrec a)] -> ReadPrec a | ||||||||||||||||||||||||||||||||||||||||
Parse the specified lexeme and continue as specified. Esp useful for nullary constructors; e.g. choose [("A", return A), ("B", return B)] | ||||||||||||||||||||||||||||||||||||||||
readListDefault :: Read a => ReadS [a] | ||||||||||||||||||||||||||||||||||||||||
A possible replacement definition for the readList method (GHC only). This is only needed for GHC, and even then only for Read instances where readListPrec isn't defined as readListPrecDefault. | ||||||||||||||||||||||||||||||||||||||||
readListPrecDefault :: Read a => ReadPrec [a] | ||||||||||||||||||||||||||||||||||||||||
A possible replacement definition for the readListPrec method, defined using readPrec (GHC only). | ||||||||||||||||||||||||||||||||||||||||
readParen :: Bool -> ReadS a -> ReadS a | ||||||||||||||||||||||||||||||||||||||||
readParen True p parses what p parses, but surrounded with parentheses. readParen False p parses what p parses, but optionally surrounded with parentheses. | ||||||||||||||||||||||||||||||||||||||||
Produced by Haddock version 2.2.2 |