[project @ 2004-12-02 15:57:02 by ross]
[packages/random.git] / Text / Read.hs
1 {-# OPTIONS -fno-implicit-prelude #-}
2 -----------------------------------------------------------------------------
3 -- |
4 -- Module : Text.Read
5 -- Copyright : (c) The University of Glasgow 2001
6 -- License : BSD-style (see the file libraries/base/LICENSE)
7 --
8 -- Maintainer : libraries@haskell.org
9 -- Stability : provisional
10 -- Portability : non-portable (uses Text.ParserCombinators.ReadP)
11 --
12 -- Converting strings to values.
13 --
14 -- The "Text.Read" library is the canonical library to import for
15 -- 'Read'-class facilities. For GHC only, it offers an extended and much
16 -- improved 'Read' class, which constitutes a proposed alternative to the
17 -- Haskell 98 'Read'. In particular, writing parsers is easier, and
18 -- the parsers are much more efficient.
19 --
20 -----------------------------------------------------------------------------
21
22 module Text.Read (
23 -- * The 'Read' class
24 Read(..), -- The Read class
25 ReadS, -- String -> Maybe (a,String)
26
27 -- * Haskell 98 functions
28 reads, -- :: (Read a) => ReadS a
29 read, -- :: (Read a) => String -> a
30 readParen, -- :: Bool -> ReadS a -> ReadS a
31 lex, -- :: ReadS String
32
33 #if defined(__GLASGOW_HASKELL__) || defined(__HUGS__)
34 -- * New parsing functions
35 module Text.ParserCombinators.ReadPrec,
36 L.Lexeme(..),
37 lexP, -- :: ReadPrec Lexeme
38 #endif
39 #ifdef __GLASGOW_HASKELL__
40 readListDefault, -- :: Read a => ReadS [a]
41 readListPrecDefault, -- :: Read a => ReadPrec [a]
42 #endif
43
44 ) where
45
46 #ifdef __GLASGOW_HASKELL__
47 import GHC.Read
48 #endif
49 #if defined(__GLASGOW_HASKELL__) || defined(__HUGS__)
50 import Text.ParserCombinators.ReadPrec
51 import qualified Text.Read.Lex as L
52 #endif
53
54 #ifdef __HUGS__
55 -- copied from GHC.Read
56
57 lexP :: ReadPrec L.Lexeme
58 lexP = lift L.lex
59 #endif