|
Generics.EMGM.Functions.Read | Portability | non-portable | Stability | experimental | Maintainer | generics@haskell.org |
|
|
|
Description |
Summary: Generic functions that parse strings to produce values.
The functions in this module involve generically parsing a string and
producing a value. They rely on the return type to determine the structure
for parsing. Often, this can be determined by the type checker, but
you will occasionally need to give an explicit type signature.
The underlying parser is designed to be as similar to deriving Read (as
implemented by GHC) as possible. Refer to documentation in Text.Read for
details.
Since this library does not have access to the syntax of a data
declaration, it relies on ConDescr for information. It is important that
ConDescr accurately describe, for each constructor, the name, record
labels (in same order as declared) if present, and fixity.
See also Generics.EMGM.Functions.Show.
|
|
Synopsis |
|
|
|
Documentation |
|
|
The type of a generic function that takes a constructor-type argument and
returns a parser combinator for some type.
| Constructors | | Instances | Generic Read | Rep Read String | Rep Read () | Rep Read a => Rep Read ([] a) | (Rep Read a, Rep Read b) => Rep Read ((,) a b) | (Rep Read a, Rep Read b, Rep Read c) => Rep Read ((,,) a b c) | (Rep Read a, Rep Read b, Rep Read c, Rep Read d) => Rep Read ((,,,) a b c d) | (Rep Read a, Rep Read b, Rep Read c, Rep Read d, Rep Read e) => Rep Read ((,,,,) a b c d e) | (Rep Read a, Rep Read b, Rep Read c, Rep Read d, Rep Read e, Rep Read f) => Rep Read ((,,,,,) a b c d e f) | (Rep Read a, Rep Read b, Rep Read c, Rep Read d, Rep Read e, Rep Read f, Rep Read h) => Rep Read ((,,,,,,) a b c d e f h) |
|
|
|
|
Generate a ReadPrec parser combinator for the datatype a that handles
operator precedence. This uses the library in
Text.ParserCombinators.ReadPrec and should be similar to a derived
implementation of Text.Read.readPrec.
|
|
|
:: Rep Read a | | => Int | Operator precedence of the enclosing context (a number from 0 to 11).
| -> ReadP a | | Generate a ReadP parser combinator for the datatype a. This can be used
with Text.ParserCombinators.ReadP.
|
|
|
|
:: Rep Read a | | => Int | Operator precedence of the enclosing context (a number from 0 to 11).
| -> ReadS a | Equivalent to String -> [(a,String)].
| Attempt to parse a value from the front of the string using the given
precedence. readsPrec returns a list of (parsed value, remaining string)
pairs. If parsing fails, readsPrec returns an empty list.
|
|
|
|
A variant of readsPrec with the minimum precedence (0).
|
|
|
A variant of reads that returns Just value on a successful parse.
Otherwise, read returns Nothing. Note that a successful parse requires
the input to be completely consumed.
|
|
Produced by Haddock version 2.4.2 |