@@ -13,8 +13,8 @@ module Streamly.Internal.Network.Socket
14 SockSpec (..)
14 SockSpec (..)
15 -- * Use a socket
15 -- * Use a socket
16− , handleWithM
16+ , forSocketM
17− , handleWith
17+ , withSocket
19 -- * Accept connections
19 -- * Accept connections
@@ -105,25 +105,27 @@ import qualified Streamly.Internal.Data.Array.Foreign.Type as A
105import qualified Streamly.Internal.Data.Stream.IsStream as S
105import qualified Streamly.Internal.Data.Stream.IsStream as S
106import qualified Streamly.Internal.Data.Stream.StreamD.Type as D
106import qualified Streamly.Internal.Data.Stream.StreamD.Type as D
108−-- | @'handleWithM' socket act@ runs the monadic computation @act@ passing the
108+-- | @'forSocketM' action socket@ runs the monadic computation @action@ passing
109−-- socket handle to it. The handle will be closed on exit from 'handleWithM',
109+-- the socket handle to it. The handle will be closed on exit from
110−-- whether by normal termination or by raising an exception. If closing the
110+-- 'forSocketM', whether by normal termination or by raising an exception. If
111−-- handle raises an exception, then this exception will be raised by
111+-- closing the handle raises an exception, then this exception will be raised
112−-- 'handleWithM' rather than any exception raised by 'act'.
112+-- by 'forSocketM' rather than any exception raised by 'action'.
114−-- @since 0.7.0
114+-- @since 0.8.0
115−{-# INLINE handleWithM #-}
115+{-# INLINE forSocketM #-}
116−handleWithM :: (MonadMask m, MonadIO m) => (Socket -> m ()) -> Socket -> m ()
116+forSocketM :: (MonadMask m, MonadIO m) => (Socket -> m ()) -> Socket -> m ()
117−handleWithM f sk = finally (f sk) (liftIO (Net.close sk))
117+forSocketM f sk = finally (f sk) (liftIO (Net.close sk))
119−-- | Like 'handleWithM' but runs a streaming computation instead of a monadic
119+-- | Like 'forSocketM' but runs a streaming computation instead of a monadic
120-- computation.
120-- computation.
122−-- @since 0.7.0
122+-- /Inhibits stream fusion/
123−{-# INLINE handleWith #-}
123+--
125+{-# INLINE withSocket #-}
124−handleWith :: (IsStream t, MonadAsync m, MonadCatch m)
126+withSocket :: (IsStream t, MonadAsync m, MonadCatch m)
125 => Socket -> (Socket -> t m a) -> t m a
127 => 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)
128-------------------------------------------------------------------------------
130-------------------------------------------------------------------------------
129-- Accept (Unfolds)
131-- Accept (Unfolds)