Hack around the non-portable ReadP library to allow nhc98 to use Data.Version.
--
-- Maintainer : libraries@haskell.org
-- Stability : experimental
--
-- Maintainer : libraries@haskell.org
-- Stability : experimental
--- Portability : portable
+-- Portability : non-portable (local universal quantification in ReadP)
--
-- A general library for representation and manipulation of versions.
--
--
-- A general library for representation and manipulation of versions.
--
-- of GHC. In which case, we might need to pick up ReadP from
-- Distribution.Compat.ReadP, because the version in
-- Text.ParserCombinators.ReadP doesn't have all the combinators we need.
-- of GHC. In which case, we might need to pick up ReadP from
-- Distribution.Compat.ReadP, because the version in
-- Text.ParserCombinators.ReadP doesn't have all the combinators we need.
-#if __GLASGOW_HASKELL__ >= 603 || __HUGS__
+#if __GLASGOW_HASKELL__ >= 603 || __HUGS__ || __NHC__
import Text.ParserCombinators.ReadP
#else
import Distribution.Compat.ReadP
import Text.ParserCombinators.ReadP
#else
import Distribution.Compat.ReadP
-- | A parser for versions in the format produced by 'showVersion'.
--
-- | A parser for versions in the format produced by 'showVersion'.
--
-#if __GLASGOW_HASKELL__ <= 602 && !__HUGS__
+#if __GLASGOW_HASKELL__ <= 602 && !__HUGS__ && !__NHC__
parseVersion :: ReadP r Version
parseVersion :: ReadP r Version
+#elif __NHC__
+parseVersion :: ReadPN r Version
#else
parseVersion :: ReadP Version
#endif
#else
parseVersion :: ReadP Version
#endif
Text/PrettyPrint/HughesPJ.hs Text/PrettyPrint.hs \
Text/Html/BlockTable.hs Text/Html.hs Text/Printf.hs \
Text/Read.hs Text/Show.hs Text/Show/Functions.hs \
Text/PrettyPrint/HughesPJ.hs Text/PrettyPrint.hs \
Text/Html/BlockTable.hs Text/Html.hs Text/Printf.hs \
Text/Read.hs Text/Show.hs Text/Show/Functions.hs \
+ Text/ParserCombinators/ReadP.hs Data/Version.hs
-# Text/ParserCombinators/ReadP.hs Text/ParserCombinators/ReadPrec.hs
-# Data/Version.hs \
+# Text/ParserCombinators/ReadPrec.hs
# [Data/Dynamic.hs] Data/Generics.hs Data/STRef.hs Data/Unique.hs
# System/Mem.hs System/Mem/StableName.hs System/Mem/Weak.hs
# System/Posix/Types.hs System/Posix/Signals.hsc
# [Data/Dynamic.hs] Data/Generics.hs Data/STRef.hs Data/Unique.hs
# System/Mem.hs System/Mem/StableName.hs System/Mem/Weak.hs
# System/Posix/Types.hs System/Posix/Signals.hsc
module Text.ParserCombinators.ReadP
(
-- * The 'ReadP' type
module Text.ParserCombinators.ReadP
(
-- * The 'ReadP' type
ReadP, -- :: * -> *; instance Functor, Monad, MonadPlus
ReadP, -- :: * -> *; instance Functor, Monad, MonadPlus
+#else
+ ReadPN, -- :: * -> * -> *; instance Functor, Monad, MonadPlus
+#endif
-- * Primitive operations
get, -- :: ReadP Char
-- * Primitive operations
get, -- :: ReadP Char
-- ---------------------------------------------------------------------------
-- The ReadP type
-- ---------------------------------------------------------------------------
-- The ReadP type
newtype ReadP a = R (forall b . (a -> P b) -> P b)
newtype ReadP a = R (forall b . (a -> P b) -> P b)
+#else
+#define ReadP (ReadPN b)
+newtype ReadPN b a = R ((a -> P b) -> P b)
+#endif
-- Functor, Monad, MonadPlus
-- Functor, Monad, MonadPlus
-- ^ Symmetric choice.
R f1 +++ R f2 = R (\k -> f1 k `mplus` f2 k)
-- ^ Symmetric choice.
R f1 +++ R f2 = R (\k -> f1 k `mplus` f2 k)
(<++) :: ReadP a -> ReadP a -> ReadP a
(<++) :: ReadP a -> ReadP a -> ReadP a
+#else
+(<++) :: ReadPN a a -> ReadPN a a -> ReadPN a a
+#endif
-- ^ Local, exclusive, left-biased choice: If left parser
-- locally produces any result at all, then right parser is
-- not used.
-- ^ Local, exclusive, left-biased choice: If left parser
-- locally produces any result at all, then right parser is
-- not used.
discard n = get >> discard (n-1)
#endif
discard n = get >> discard (n-1)
#endif
gather :: ReadP a -> ReadP (String, a)
gather :: ReadP a -> ReadP (String, a)
+#else
+-- gather :: ReadPN (String->P b) a -> ReadPN (String->P b) (String, a)
+#endif
-- ^ Transforms a parser into one that does the same, but
-- in addition returns the exact characters read.
-- IMPORTANT NOTE: 'gather' gives a runtime error if its first argument
-- ^ Transforms a parser into one that does the same, but
-- in addition returns the exact characters read.
-- IMPORTANT NOTE: 'gather' gives a runtime error if its first argument
rest (f x y)
+++ return x
rest (f x y)
+++ return x
manyTill :: ReadP a -> ReadP end -> ReadP [a]
manyTill :: ReadP a -> ReadP end -> ReadP [a]
+#else
+manyTill :: ReadPN [a] a -> ReadPN [a] end -> ReadPN [a] [a]
+#endif
-- ^ @manyTill p end@ parses zero or more occurrences of @p@, until @end@
-- succeeds. Returns a list of values returned by @p@.
manyTill p end = scan
-- ^ @manyTill p end@ parses zero or more occurrences of @p@, until @end@
-- succeeds. Returns a list of values returned by @p@.
manyTill p end = scan
-- ---------------------------------------------------------------------------
-- Converting between ReadP and Read
-- ---------------------------------------------------------------------------
-- Converting between ReadP and Read
readP_to_S :: ReadP a -> ReadS a
readP_to_S :: ReadP a -> ReadS a
+#else
+readP_to_S :: ReadPN a a -> ReadS a
+#endif
-- ^ 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
-- ^ 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