@@ -13,8 +13,8 @@ module Streamly.Internal.Network.Socket
1313 (
1414 SockSpec (..)
1515 -- * Use a socket
16− , handleWithM
17− , handleWith
16+ , forSocketM
17+ , withSocket
1818
1919 -- * Accept connections
2020 , accept
@@ -105,25 +105,27 @@ import qualified Streamly.Internal.Data.Array.Foreign.Type as A
105105import qualified Streamly.Internal.Data.Stream.IsStream as S
106106import qualified Streamly.Internal.Data.Stream.StreamD.Type as D
107107
108−-- | @'handleWithM' socket act@ runs the monadic computation @act@ passing the
109−-- socket handle to it. The handle will be closed on exit from 'handleWithM',
110−-- whether by normal termination or by raising an exception. If closing the
111−-- handle raises an exception, then this exception will be raised by
112−-- 'handleWithM' rather than any exception raised by 'act'.
108+-- | @'forSocketM' action socket@ runs the monadic computation @action@ passing
109+-- the socket handle to it. The handle will be closed on exit from
110+-- 'forSocketM', whether by normal termination or by raising an exception. If
111+-- closing the handle raises an exception, then this exception will be raised
112+-- by 'forSocketM' rather than any exception raised by 'action'.
113113--
114−-- @since 0.7.0
115−{-# INLINE handleWithM #-}
116−handleWithM :: (MonadMask m, MonadIO m) => (Socket -> m ()) -> Socket -> m ()
117−handleWithM f sk = finally (f sk) (liftIO (Net.close sk))
114+-- @since 0.8.0
115+{-# INLINE forSocketM #-}
116+forSocketM :: (MonadMask m, MonadIO m) => (Socket -> m ()) -> Socket -> m ()
117+forSocketM f sk = finally (f sk) (liftIO (Net.close sk))
118118
119−-- | Like 'handleWithM' but runs a streaming computation instead of a monadic
119+-- | Like 'forSocketM' but runs a streaming computation instead of a monadic
120120-- computation.
121121--
122−-- @since 0.7.0
123−{-# INLINE handleWith #-}
124−handleWith :: (IsStream t, MonadAsync m, MonadCatch m)
122+-- /Inhibits stream fusion/
123+--
124+-- /Internal/
125+{-# INLINE withSocket #-}
126+withSocket :: (IsStream t, MonadAsync m, MonadCatch m)
125127 => Socket -> (Socket -> t m a) -> t m a
126−handleWith sk f = S.finally (liftIO $ Net.close sk) (f sk)
128+withSocket sk f = S.finally (liftIO $ Net.close sk) (f sk)
127129
128130-------------------------------------------------------------------------------
129131-- Accept (Unfolds)