Correct the order of arguments in finally.
commit3315e1a6154f2415b728a69109d45091ad65b6ab
authorHarendra Kumar <harendra.kumar@gmail.com>
dateThu 14 Nov 2019, 13:54 (7 years ago)
parenta65148c
examples/EchoServer.hs+2−2
@@ -11,9 +11,9 @@ import qualified Streamly.Prelude as S
1111main :: IO ()
1212main = S.drain
1313 $ parallely $ S.mapM (useWith echo)
14− $ serially $ S.unfold TCP.acceptOnPort 8090
14+ $ serially $ S.unfold TCP.acceptOnPort 8091
1515 where
1616 echo sk =
1717 S.fold (writeChunks sk)
1818 $ S.unfold readChunksWithBufferOf (32768, sk)
19− useWith f sk = finally (liftIO (Net.close sk)) (f sk)
19+ useWith f sk = finally (f sk) (liftIO (Net.close sk))
src/Streamly/Internal/Network/Socket.hs+1−1
@@ -117,7 +117,7 @@ import qualified Streamly.Internal.Data.Stream.StreamD.Type as D
117117-- @since 0.7.0
118118{-# INLINE useSocketM #-}
119119useSocketM :: (MonadMask m, MonadIO m) => Socket -> (Socket -> m ()) -> m ()
120−useSocketM sk f = finally (liftIO (Net.close sk)) (f sk)
120+useSocketM sk f = finally (f sk) (liftIO (Net.close sk))
121121
122122-- | Like 'useSocketM' but runs a streaming computation instead of a monadic
123123-- computation.