network-conduit 0.2.1.1 → 0.2.1.2
raw patch · 2 files changed
+20/−12 lines, 2 filesdep +lifted-basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: lifted-base
API changes (from Hackage documentation)
- Data.Conduit.Network: runTCPClient :: ClientSettings -> Application -> IO ()
+ Data.Conduit.Network: runTCPClient :: ResourceIO m => ClientSettings -> ApplicationM m -> m ()
- Data.Conduit.Network: runTCPServer :: ServerSettings -> Application -> IO ()
+ Data.Conduit.Network: runTCPServer :: (Base m ~ IO, ResourceIO m) => ServerSettings -> ApplicationM m -> m ()
Files
- Data/Conduit/Network.hs +17/−10
- network-conduit.cabal +3/−2
Data/Conduit/Network.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeFamilies #-} module Data.Conduit.Network ( -- * Basic utilities sourceSocket@@ -23,10 +24,11 @@ import Data.ByteString (ByteString) import qualified Data.ByteString as S import Control.Monad.IO.Class (liftIO)-import Control.Exception (bracketOnError, IOException, bracket, throwIO, SomeException, try)+import Control.Exception (bracketOnError, IOException, throwIO, SomeException, try)+import Control.Exception.Lifted (bracket) import Control.Monad (forever) import Control.Monad.Trans.Resource (register)-import Control.Concurrent (forkIO)+import Control.Concurrent.Lifted (fork) -- | Stream data from the socket. --@@ -66,6 +68,11 @@ -> Sink ByteString IO () -> ResourceT IO () +-- | Same as @Application@, but allows an arbitrary inner monad.+type ApplicationM m = Source m ByteString+ -> Sink ByteString m ()+ -> ResourceT m ()+ -- | Settings for a TCP server. It takes a port to listen on, and an optional -- hostname to bind to. --@@ -80,15 +87,15 @@ -- each connection. -- -- Since 0.2.1-runTCPServer :: ServerSettings -> Application -> IO ()+runTCPServer :: (Base m ~ IO, ResourceIO m) => ServerSettings -> ApplicationM m -> m () runTCPServer (ServerSettings port host) app = bracket- (bindPort host port)- NS.sClose+ (liftIO $ bindPort host port)+ (liftIO . NS.sClose) (forever . serve) where serve lsocket = do- (socket, _addr) <- NS.accept lsocket- forkIO $ runResourceT $ do+ (socket, _addr) <- liftIO $ NS.accept lsocket+ fork $ runResourceT $ do _ <- register $ NS.sClose socket app (sourceSocket socket) (sinkSocket socket) @@ -101,10 +108,10 @@ -- | Run an @Application@ by connecting to the specified server. -- -- Since 0.2.1-runTCPClient :: ClientSettings -> Application -> IO ()+runTCPClient :: ResourceIO m => ClientSettings -> ApplicationM m -> m () runTCPClient (ClientSettings port host) app = bracket- (getSocket host port)- NS.sClose+ (liftIO $ getSocket host port)+ (liftIO . NS.sClose) (\s -> runResourceT $ app (sourceSocket s) (sinkSocket s)) -- | Attempt to connect to the given host/port.
network-conduit.cabal view
@@ -1,5 +1,5 @@ Name: network-conduit-Version: 0.2.1.1+Version: 0.2.1.2 Synopsis: Stream socket data using conduits. Description: Stream socket data using conduits. License: BSD3@@ -20,7 +20,8 @@ Build-depends: base >= 4 && < 5 , transformers >= 0.2.2 && < 0.3 , bytestring >= 0.9- , conduit >= 0.2+ , conduit >= 0.2 && < 0.3+ , lifted-base >= 0.1 && < 0.2 if flag(network-bytestring) build-depends: network >= 2.2.1 && < 2.2.3 , network-bytestring >= 0.1.3 && < 0.1.4