5ba1fcb7fac853abba684f9b793e0568277126aa
[ghc-base.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 -- The "Text.Read" library is the canonical library to import for
13 -- 'Read'-class facilities.  For GHC only, it offers an extended and much
14 -- improved 'Read' class, which constitutes a proposed alternative to the 
15 -- Haskell 98 'Read'.  In particular, writing parsers is easier, and
16 -- the parsers are much more efficient.
17 --
18 -----------------------------------------------------------------------------
19
20 module Text.Read (
21    -- * The 'Read' class
22    Read(..),            -- The Read class
23    ReadS,               -- String -> Maybe (a,String)
24
25    -- * Haskell 98 functions
26    reads,               -- :: (Read a) => ReadS a
27    read,                -- :: (Read a) => String -> a
28    readParen,           -- :: Bool -> ReadS a -> ReadS a
29    lex,                 -- :: ReadS String
30
31 #if defined(__GLASGOW_HASKELL__) || defined(__HUGS__)
32    -- * New parsing functions
33    module Text.ParserCombinators.ReadPrec,
34    L.Lexeme(..),        
35    lexP,                -- :: ReadPrec Lexeme
36 #endif
37 #ifdef __GLASGOW_HASKELL__
38    readListDefault,     -- :: Read a => ReadS [a]
39    readListPrecDefault, -- :: Read a => ReadPrec [a]
40 #endif
41
42  ) where
43
44 #ifdef __GLASGOW_HASKELL__
45 import GHC.Read
46 #endif   
47 #if defined(__GLASGOW_HASKELL__) || defined(__HUGS__)
48 import Text.ParserCombinators.ReadPrec
49 import qualified Text.Read.Lex as L
50 #endif   
51
52 #ifdef __HUGS__
53 -- copied from GHC.Read
54
55 lexP :: ReadPrec L.Lexeme
56 lexP = lift L.lex
57 #endif