Commit 8b908365 authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺

Move (=<<) to GHC.Base

This allows GHC.Stack to avoid importing Control.Monad, and
is preparatory work for implementing #9586

Reviewed By: austin

Differential Revision: https://phabricator.haskell.org/D221
parent c4c89245
......@@ -81,17 +81,11 @@ import Data.Maybe
import GHC.List
import GHC.Base
infixr 1 =<<
infixl 3 <|>
-- -----------------------------------------------------------------------------
-- Prelude monad functions
-- | Same as '>>=', but with the arguments interchanged.
{-# SPECIALISE (=<<) :: (a -> [b]) -> [a] -> [b] #-}
(=<<) :: Monad m => (a -> m b) -> m a -> m b
f =<< x = x >>= f
-- | Evaluate each action in the sequence from left to right,
-- and collect the results.
sequence :: Monad m => [m a] -> m [a]
......
......@@ -121,6 +121,7 @@ infixr 9 .
infixr 5 ++
infixl 4 <$
infixl 1 >>, >>=
infixr 1 =<<
infixr 0 $, $!
infixl 4 <*>, <*, *>, <**>
......@@ -487,6 +488,11 @@ original default.
-}
-- | Same as '>>=', but with the arguments interchanged.
{-# SPECIALISE (=<<) :: (a -> [b]) -> [a] -> [b] #-}
(=<<) :: Monad m => (a -> m b) -> m a -> m b
f =<< x = x >>= f
-- | Promote a function to a monad.
liftM :: (Monad m) => (a1 -> r) -> m a1 -> m r
liftM f m1 = do { x1 <- m1; return (f x1) }
......
......@@ -52,7 +52,7 @@ module GHC.Event.Manager
import Control.Concurrent.MVar (MVar, newMVar, readMVar, putMVar,
tryPutMVar, takeMVar, withMVar)
import Control.Exception (onException)
import Control.Monad ((=<<), forM_, when, replicateM, void)
import Control.Monad (forM_, when, replicateM, void)
import Data.Bits ((.&.))
import Data.IORef (IORef, atomicModifyIORef', mkWeakIORef, newIORef, readIORef,
writeIORef)
......
......@@ -26,7 +26,7 @@ available = False
#include <poll.h>
import Control.Concurrent.MVar (MVar, newMVar, swapMVar)
import Control.Monad ((=<<), unless)
import Control.Monad (unless)
import Data.Bits (Bits, FiniteBits, (.|.), (.&.))
import Data.Word
import Foreign.C.Types (CInt(..), CShort(..))
......
......@@ -39,7 +39,7 @@ module GHC.Event.TimerManager
-- Imports
import Control.Exception (finally)
import Control.Monad ((=<<), sequence_, when)
import Control.Monad (sequence_, when)
import Data.IORef (IORef, atomicModifyIORef', mkWeakIORef, newIORef, readIORef,
writeIORef)
import GHC.Base
......
......@@ -34,8 +34,6 @@ module GHC.Stack (
renderStack
) where
import Control.Monad ( (=<<) )
import Foreign
import Foreign.C
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment