[project @ 2003-11-02 00:06:23 by panne]
[ghc-base.git] / Text / ParserCombinators / ReadPrec.hs
index 50cef1e..1fbada4 100644 (file)
@@ -7,7 +7,7 @@
 -- 
 -- Maintainer  :  libraries@haskell.org
 -- Stability   :  provisional
--- Portability :  portable
+-- Portability :  non-portable (uses Text.ParserCombinators.ReadP)
 --
 -- This library defines parser combinators for precedence parsing.
 
@@ -32,6 +32,7 @@ module Text.ParserCombinators.ReadPrec
   get,           -- :: ReadPrec Char
   look,          -- :: ReadPrec String
   (+++),         -- :: ReadPrec a -> ReadPrec a -> ReadPrec a
+  (<++),         -- :: ReadPrec a -> ReadPrec a -> ReadPrec a
   pfail,         -- :: ReadPrec a
   choice,        -- :: [ReadPrec a] -> ReadPrec a
 
@@ -46,6 +47,7 @@ module Text.ParserCombinators.ReadPrec
 
 import Text.ParserCombinators.ReadP
   ( ReadP
+  , ReadS
   , readP_to_S
   , readS_to_P
   )
@@ -53,14 +55,15 @@ import Text.ParserCombinators.ReadP
 import qualified Text.ParserCombinators.ReadP as ReadP
   ( get
   , look
-  , (+++)
+  , (+++), (<++)
   , pfail
-  , choice
   )
 
 import Control.Monad( MonadPlus(..) )
+#ifdef __GLASGOW_HASKELL__
 import GHC.Num( Num(..) )
 import GHC.Base
+#endif
 
 -- ---------------------------------------------------------------------------
 -- The readPrec type
@@ -122,6 +125,9 @@ look = lift ReadP.look
 (+++) :: ReadPrec a -> ReadPrec a -> ReadPrec a
 P f1 +++ P f2 = P (\n -> f1 n ReadP.+++ f2 n)
 
+(<++) :: ReadPrec a -> ReadPrec a -> ReadPrec a
+P f1 <++ P f2 = P (\n -> f1 n ReadP.<++ f2 n)
+
 pfail :: ReadPrec a
 pfail = lift ReadP.pfail
 
@@ -131,10 +137,6 @@ choice ps = foldr (+++) pfail ps
 -- ---------------------------------------------------------------------------
 -- Converting between ReadPrec and Read
 
--- We define a local version of ReadS here,
--- because its "real" definition site is in GHC.Read
-type ReadS a = String -> [(a,String)]
-
 readPrec_to_P :: ReadPrec a -> (Int -> ReadP a)
 readPrec_to_P (P f) = f