GHC.Read

| Haskell Hierarchical Libraries (base package) | Contents | Index
GHC.Read |
Portability | non-portable (GHC Extensions)
Stability | internal
Maintainer | cvs-ghc@haskell.org
Description
The `Read` class and instances for basic data types.
Synopsis
class Read a where
readsPrec :: Int -> ReadS a
readList :: ReadS [a]
readPrec :: ReadPrec a
readListPrec :: ReadPrec [a]
type ReadS a = String -> [(a, String)]
reads :: Read a => ReadS a
readp :: Read a => ReadP a
readEither :: Read a => String -> Either String a
read :: Read a => String -> a
lex :: ReadS String
lexLitChar :: ReadS String
readLitChar :: ReadS Char
lexDigits :: ReadS String
lexP :: ReadPrec Lexeme
paren :: ReadPrec a -> ReadPrec a
parens :: ReadPrec a -> ReadPrec a
list :: ReadPrec a -> ReadPrec [a]
choose :: [(String, ReadPrec a)] -> ReadPrec a
readListDefault :: Read a => ReadS [a]
readListPrecDefault :: Read a => ReadPrec [a]
readParen :: Bool -> ReadS a -> ReadS a
Documentation
class Read a where
Methods
readsPrec :: Int -> ReadS a
readList :: ReadS [a]
readPrec :: ReadPrec a
Proposed replacement for `readsPrec` using new-style parsers (GHC only).
readListPrec :: ReadPrec [a]
Proposed replacement for `readList` using new-style parsers (GHC only).
Instances
(RealFloat a, Read a) => Read (Complex a)
Read CChar
Read CSChar
Read CUChar
Read CShort
Read CUShort
Read CInt
Read CUInt
Read CLong
Read CULong
Read CLLong
Read CULLong
Read CFloat
Read CDouble
Read CLDouble
Read CPtrdiff
Read CSize
Read CWchar
Read CSigAtomic
Read CClock
Read CTime
Read SeekMode
Read BufferMode
Read ExitCode
Read IOMode
Read Int8
Read Int16
Read Int32
Read Int64
Read Char
Read Bool
Read Ordering
Read a => Read (Maybe a)
(Read a, Read b) => Read (Either a b)
Read a => Read [a]
(Ix a, Read a, Read b) => Read (Array a b)
Read Lexeme
Read Int
Read Integer
Read Float
Read Double
(Integral a, Read a) => Read (Ratio a)
Read ()
(Read a, Read b) => Read (a, b)
(Read a, Read b, Read c) => Read (a, b, c)
(Read a, Read b, Read c, Read d) => Read (a, b, c, d)
(Read a, Read b, Read c, Read d, Read e) => Read (a, b, c, d, e)
Read Word
Read Word8
Read Word16
Read Word32
Read Word64
Read Permissions
Read CDev
Read CIno
Read CMode
Read COff
Read CPid
Read CSsize
Read CGid
Read CNlink
Read CUid
Read CCc
Read CSpeed
Read CTcflag
Read CRLim
Read Fd
Read StdGen
Read Month
Read Day
Read CalendarTime
Read TimeDiff
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 `(a,`String`)` pairs.
reads :: Read a => ReadS a
readp :: Read a => ReadP a
readEither :: Read a => String -> Either String a
read :: Read a => String -> a
lex :: ReadS String
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
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 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]
Use this to define the `readList` method, if you don't want a special case (GHC only; for other systems the default suffices).
readListPrecDefault :: Read a => ReadPrec [a]
Use this to define the `readListPrec` method, if you don't want a special case (GHC only).
readParen :: Bool -> ReadS a -> ReadS a
Produced by Haddock version 0.6