diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2014-09-18 23:05:47 +0200 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2014-09-18 23:13:02 +0200 |
commit | af22696b8f6d8b677c33f70537a5999ad94266cd (patch) | |
tree | b42bdce024635772b58fe55e72a649eb1f2ea67e /libraries/base/Text | |
parent | fbf1e3065bf32317db8e87afe8a58ceee2c02241 (diff) | |
download | haskell-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.hs | 5 | ||||
-rw-r--r-- | libraries/base/Text/Read/Lex.hs | 8 |
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 |