[commit: ghc] master: Fix mistaken merge (b2f10d8)

git at git.haskell.org git at git.haskell.org
Fri Jan 12 20:48:34 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/b2f10d8981bebe44f1ab39e417818dfa2d50639d/ghc

>---------------------------------------------------------------

commit b2f10d8981bebe44f1ab39e417818dfa2d50639d
Author: Ben Gamari <ben at smart-cactus.org>
Date:   Fri Jan 12 15:03:11 2018 -0500

    Fix mistaken merge
    
    When merging D4259 I had to resort to manual merge due to some conflicts that
    arc couldn't sort out. Unfortunately in the process I merged the wrong version
    of the patch. Fix this. Thanks to @ntc2 for the great documentation and noticing
    my mistake.


>---------------------------------------------------------------

b2f10d8981bebe44f1ab39e417818dfa2d50639d
 libraries/base/Control/Monad.hs | 37 +++++++++++++++----------------------
 1 file changed, 15 insertions(+), 22 deletions(-)

diff --git a/libraries/base/Control/Monad.hs b/libraries/base/Control/Monad.hs
index d9bfdeb..09066c7 100644
--- a/libraries/base/Control/Monad.hs
+++ b/libraries/base/Control/Monad.hs
@@ -156,33 +156,26 @@ f >=> g     = \x -> f x >>= g
 --
 -- ==== __Examples__
 --
--- Simple network servers can be created by writing a function to
--- handle a single client connection and then using 'forever' to
--- accept client connections and fork threads to handle them.
+-- A common use of 'forever' is to process input from network sockets,
+-- 'System.IO.Handle's, and channels
+-- (e.g. 'Control.Concurrent.MVar.MVar' and
+-- 'Control.Concurrent.Chan.Chan').
 --
--- For example, here is a [TCP echo
--- server](https://en.wikipedia.org/wiki/Echo_Protocol) implemented
--- with 'forever':
+-- For example, here is how we might implement an [echo
+-- server](https://en.wikipedia.org/wiki/Echo_Protocol), using
+-- 'forever' both to listen for client connections on a network socket
+-- and to echo client input on client connection handles:
 --
 -- @
--- import "Control.Concurrent" ( 'Control.Concurrent.forkFinally' )
--- import "Control.Monad"      ( 'forever' )
--- import Network            ( PortID(..), accept, listenOn )
--- import "System.IO"          ( 'System.IO.hClose', 'System.IO.hGetLine', 'System.IO.hPutStrLn' )
---
--- main :: IO ()
--- main = do
---   sock <- listenOn (PortNumber 7)
---   'forever' $ do
---     (handle, _, _) <- accept sock
---     echo handle \`forkFinally\` const (hClose handle)
+-- echoServer :: Socket -> IO ()
+-- echoServer socket = 'forever' $ do
+--   client <- accept socket
+--   'Control.Concurrent.forkFinally' (echo client) (\\_ -> hClose client)
 --   where
---     echo handle = 'forever' $
---       hGetLine handle >>= hPutStrLn handle
+--     echo :: Handle -> IO ()
+--     echo client = 'forever' $
+--       hGetLine client >>= hPutStrLn client
 -- @
---
--- The @Network@ module is provided by the [network
--- package](https://hackage.haskell.org/package/network).
 forever     :: (Applicative f) => f a -> f b
 {-# INLINE forever #-}
 forever a   = let a' = a *> a' in a'



More information about the ghc-commits mailing list