[project @ 2004-01-02 19:03:14 by panne]
[haskell-directory.git] / Text / ParserCombinators / ReadP.hs
index f478230..6b8475f 100644 (file)
@@ -40,6 +40,7 @@ module Text.ParserCombinators.ReadP
   choice,     -- :: [ReadP a] -> ReadP a
   
   -- * Running a parser
+  ReadS,      -- :: *; = String -> [(a,String)]
   readP_to_S, -- :: ReadP a -> ReadS a
   readS_to_P, -- :: ReadS a -> ReadP a
   
@@ -50,7 +51,9 @@ module Text.ParserCombinators.ReadP
 
 import Control.Monad( MonadPlus(..) )
 #ifdef __GLASGOW_HASKELL__
-import GHC.Show( isSpace  )
+#ifndef __HADDOCK__
+import {-# SOURCE #-} GHC.Unicode ( isSpace  )
+#endif
 import GHC.Base
 #else
 import Data.Char( isSpace )
@@ -59,8 +62,11 @@ import Data.Char( isSpace )
 infixr 5 +++, <++
 
 #ifdef __GLASGOW_HASKELL__
--- We define a local version of ReadS here,
--- because its "real" definition site is in GHC.Read
+------------------------------------------------------------------------
+-- ReadS
+
+-- | A parser for a type @a@, represented as a function that takes a
+-- 'String' and returns a list of possible parses @(a,'String')@ pairs.
 type ReadS a = String -> [(a,String)]
 #endif
 
@@ -120,12 +126,7 @@ instance MonadPlus P where
 -- ---------------------------------------------------------------------------
 -- The ReadP type
 
--- newtype temporarily turned into data
--- until compiler bug as found on 26 July 2003 is fixed;
--- contact SPJ or ralf@cwi.nl
---
-data ReadP a = R (forall b . (a -> P b) -> P b)
--- newtype ReadP a = R (forall b . (a -> P b) -> P b)
+newtype ReadP a = R (forall b . (a -> P b) -> P b)
 
 -- Functor, Monad, MonadPlus
 
@@ -280,7 +281,7 @@ readP_to_S :: ReadP a -> ReadS a
 -- ^ Converts a parser into a Haskell ReadS-style function.
 --   This is the main way in which you can \"run\" a 'ReadP' parser:
 --   the expanded type is
--- @ readP_to_S :: ReadP a -> String -> [(String,String)] @
+-- @ readP_to_S :: ReadP a -> String -> [(a,String)] @
 readP_to_S (R f) = run (f return)
 
 readS_to_P :: ReadS a -> ReadP a