summaryrefslogtreecommitdiff
path: root/libraries/base/Text
diff options
context:
space:
mode:
authorHerbert Valerio Riedel <hvr@gnu.org>2014-09-18 23:05:47 +0200
committerHerbert Valerio Riedel <hvr@gnu.org>2014-09-18 23:13:02 +0200
commitaf22696b8f6d8b677c33f70537a5999ad94266cd (patch)
treeb42bdce024635772b58fe55e72a649eb1f2ea67e /libraries/base/Text
parentfbf1e3065bf32317db8e87afe8a58ceee2c02241 (diff)
downloadhaskell-af22696b8f6d8b677c33f70537a5999ad94266cd.tar.gz
Invert module-dep between Control.Monad and Data.Foldable
This is the last preparation needed before generalizing entities in Control.Monad conflicting with those from Data.Foldable (re #9586) Reviewed By: ekmett, austin Differential Revision: https://phabricator.haskell.org/D225
Diffstat (limited to 'libraries/base/Text')
-rw-r--r--libraries/base/Text/ParserCombinators/ReadP.hs5
-rw-r--r--libraries/base/Text/Read/Lex.hs8
2 files changed, 11 insertions, 2 deletions
diff --git a/libraries/base/Text/ParserCombinators/ReadP.hs b/libraries/base/Text/ParserCombinators/ReadP.hs
index 3d2b39c57e..0139e7733d 100644
--- a/libraries/base/Text/ParserCombinators/ReadP.hs
+++ b/libraries/base/Text/ParserCombinators/ReadP.hs
@@ -72,7 +72,6 @@ module Text.ParserCombinators.ReadP
)
where
-import Control.Monad ( sequence )
import {-# SOURCE #-} GHC.Unicode ( isSpace )
import GHC.List ( replicate, null )
import GHC.Base hiding ( many )
@@ -311,6 +310,10 @@ count :: Int -> ReadP a -> ReadP [a]
-- ^ @count n p@ parses @n@ occurrences of @p@ in sequence. A list of
-- results is returned.
count n p = sequence (replicate n p)
+ where -- local 'sequence' to avoid import-cycle
+ sequence ms = foldr k (return []) ms
+ where
+ k m m' = do { x <- m; xs <- m'; return (x:xs) }
between :: ReadP open -> ReadP close -> ReadP a -> ReadP a
-- ^ @between open close p@ parses @open@, followed by @p@ and finally
diff --git a/libraries/base/Text/Read/Lex.hs b/libraries/base/Text/Read/Lex.hs
index 557637d896..39ca46a33f 100644
--- a/libraries/base/Text/Read/Lex.hs
+++ b/libraries/base/Text/Read/Lex.hs
@@ -45,7 +45,13 @@ import GHC.Real( Rational, (%), fromIntegral,
import GHC.List
import GHC.Enum( minBound, maxBound )
import Data.Maybe
-import Control.Monad
+
+-- local copy to break import-cycle
+-- | @'guard' b@ is @'return' ()@ if @b@ is 'True',
+-- and 'mzero' if @b@ is 'False'.
+guard :: (MonadPlus m) => Bool -> m ()
+guard True = return ()
+guard False = mzero
-- -----------------------------------------------------------------------------
-- Lexing types