Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | generics@haskell.org |
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.
Documentation
The type of a generic function that takes a constructor-type argument and returns a parser combinator for some type.
Generic Read | |
Rep Read String | Ad-hoc instance for strings |
Rep Read () | Ad-hoc instance for |
Rep Read a => Rep Read [a] | Ad-hoc instance for lists |
(Rep Read a, Rep Read b) => Rep Read (a, b) | Ad-hoc instance for |
(Rep Read a, Rep Read b, Rep Read c) => Rep Read (a, b, c) | Ad-hoc instance for |
(Rep Read a, Rep Read b, Rep Read c, Rep Read d) => Rep Read (a, b, c, d) | Ad-hoc instance for |
(Rep Read a, Rep Read b, Rep Read c, Rep Read d, Rep Read e) => Rep Read (a, b, c, d, e) | Ad-hoc instance for |
(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) | Ad-hoc instance for |
(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) | Ad-hoc instance for |
readPrec :: Rep Read a => ReadPrec aSource
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
.