| ||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||
| Description | ||||||||||||||||||||||||||||||||||||||
Converting strings to values. The Text.Read library is the canonical library to import for Read-class facilities. For GHC only, it offers an extended and much improved Read class, which constitutes a proposed alternative to the Haskell 98 Read. In particular, writing parsers is easier, and the parsers are much more efficient. | ||||||||||||||||||||||||||||||||||||||
| Synopsis | ||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||
| The Read class | ||||||||||||||||||||||||||||||||||||||
| 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). | ||||||||||||||||||||||||||||||||||||||
| Haskell 98 functions | ||||||||||||||||||||||||||||||||||||||
| reads :: Read a => ReadS a | ||||||||||||||||||||||||||||||||||||||
| equivalent to readsPrec with a precedence of 0. | ||||||||||||||||||||||||||||||||||||||
| read :: Read a => String -> a | ||||||||||||||||||||||||||||||||||||||
| The read function reads input from a string, which must be completely consumed by the input process. | ||||||||||||||||||||||||||||||||||||||
| 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. | ||||||||||||||||||||||||||||||||||||||
| 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:
| ||||||||||||||||||||||||||||||||||||||
| New parsing functions | ||||||||||||||||||||||||||||||||||||||
| module Text.ParserCombinators.ReadPrec | ||||||||||||||||||||||||||||||||||||||
| data Lexeme | ||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||
| lexP :: ReadPrec Lexeme | ||||||||||||||||||||||||||||||||||||||
| Parse a single lexeme | ||||||||||||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||||||||||||
| 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). | ||||||||||||||||||||||||||||||||||||||
| Produced by Haddock version 2.3.0 |