network-simple-sockaddr 0.1 → 0.2
raw patch · 5 files changed
+42/−23 lines, 5 filesdep ~basedep ~exceptions
Dependency ranges changed: base, exceptions
Files
- CHANGELOG.md +14/−0
- LICENSE +2/−2
- README.md +8/−0
- network-simple-sockaddr.cabal +10/−8
- src/Network/Simple/SockAddr.hs +8/−13
+ CHANGELOG.md view
@@ -0,0 +1,14 @@+# Change Log+All notable changes to this project will be documented in this file. This+file follows the formatting recommendations from+[Keep a CHANGELOG](http://keepachangelog.com/).++## [0.2][0.2] - 2015-4-13+### Removed+- 2-Rank actions.++### Changed+- Use `MonadMask` instead of `MonadCatch`. This implies a dependency+ upgrade for `exceptions` to a `>=0.6`.++[0.2]: https://github.com/jdnavarro/compare/v0.1...v0.2
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2014, Danny Navarro+Copyright (c) 2014-2015, J. Daniel Navarro All rights reserved. @@ -13,7 +13,7 @@ disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of Danny Navarro nor the names of other+ * Neither the name of J. Daniel Navarro nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+ README.md view
@@ -0,0 +1,8 @@+# `network-simple-sockaddr`++[network-simple](http://hackage.haskell.org/package/network-simple-0.3.0 network-simple)+works by resolving `HostName`s. This packages offers a similar API but+working with unresolved addresses in the form of `SockAddr`es. In addition to+`IPv4` addresses, `IPv6` and `Unix Domain Sockets` are also supported.++[](https://hackage.haskell.org/package/network-simple-sockaddr) [](https://travis-ci.org/jdnavarro/network-simple-sockaddr.svg)
network-simple-sockaddr.cabal view
@@ -1,7 +1,7 @@ name: network-simple-sockaddr-version: 0.1+version: 0.2 cabal-version: >=1.10-tested-with: GHC == 7.6.3+tested-with: GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.1 build-type: Simple license: BSD3 license-file: LICENSE@@ -10,25 +10,27 @@ category: Network homepage: https://github.com/jdnavarro/network-simple-sockaddr bug-reports: https://github.com/jdnavarro/network-simple-sockaddr/issues+extra-source-files: README.md CHANGELOG.md synopsis: network-simple for resolved addresses+extra-source-files: README.md description: @<http://hackage.haskell.org/package/network-simple-0.3.0 network-simple>@- works by resolving 'HostName's. This packages offers a similar API but- working with unresolved addresses in the form of 'SockAddr'. In addition to- 'IPv4' addresses, 'IPv6' and @Unix Domain Sockets@ are also supported.+ works by resolving @HostName@s. This packages offers a similar API but+ working with unresolved addresses in the form of @SockAddr@. In addition to+ @IPv4@ addresses, @IPv6@ and @Unix Domain Sockets@ are also supported. source-repository head type: git- location: git@github.com:jdnavarro/network-simple-sockaddr.git+ location: git://github.com/jdnavarro/network-simple-sockaddr.git library exposed-modules: Network.Simple.SockAddr- build-depends: base >=4.6 && <4.8,+ build-depends: base >=4.6 && <4.9, bytestring, directory, transformers >=0.2, network >=2.4,- exceptions >=0.3+ exceptions >=0.6 hs-source-dirs: src default-language: Haskell2010 ghc-options: -Wall
src/Network/Simple/SockAddr.hs view
@@ -1,5 +1,3 @@-{-# LANGUAGE RankNTypes #-}- {-| This is the same API as @network-simple@ with the difference of working on 'SockAddr' instead of @'HostName's@. @@ -40,7 +38,7 @@ , defaultProtocol ) import qualified Network.Socket.ByteString as NSB-import Control.Monad.Catch (MonadCatch, bracket, bracketOnError, throwM)+import Control.Monad.Catch (MonadCatch, MonadMask, bracket, bracketOnError, throwM) -- * Client side @@ -48,7 +46,7 @@ The connection socket is closed when done or in case of exceptions. -}-connect :: (MonadIO m, MonadCatch m)+connect :: (MonadIO m, MonadMask m) => SockAddr -- ^ Server address. -> (Socket -> m r)@@ -64,8 +62,7 @@ connectFork :: MonadIO m => SockAddr -- ^ Server address.- -> (forall m' . (Functor m', MonadIO m', MonadCatch m')- => Socket -> m' ())+ -> (Socket -> IO ()) -- ^ Computation taking the socket connection socket. -> m ThreadId connectFork addr k = liftIO . forkIO $ connect addr k@@ -79,11 +76,10 @@ Any acquired network resources are properly closed and discarded when done or in case of exceptions. -}-serve :: (MonadIO m, MonadCatch m)+serve :: (MonadIO m, MonadMask m) => SockAddr -- ^ Address to bind to.- -> (forall m' . (Functor m', MonadIO m', MonadCatch m')- => SockAddr -> Socket -> m' ())+ -> (SockAddr -> Socket -> IO ()) -- ^ Computation to run in a different thread -- once an incoming connection is accepted. Takes the -- the remote end address and the connection socket.@@ -94,7 +90,7 @@ The listening socket is closed when done or in case of exceptions. -}-listen :: (MonadIO m, MonadCatch m)+listen :: (MonadIO m, MonadMask m) => SockAddr -- ^ Address to bind to. -> (Socket -> m r)@@ -114,7 +110,7 @@ within a limited scope, and would like it to be closed immediately after its usage or in case of exceptions. -}-bind :: (MonadIO m, MonadCatch m) => SockAddr -> m Socket+bind :: (MonadIO m, MonadMask m) => SockAddr -> m Socket bind addr = bracketOnError (newSocket addr) (close addr) $ \sock -> liftIO $ do let set so n = when (NS.isSupportedSocketOption so)@@ -134,8 +130,7 @@ acceptFork :: (MonadIO m, MonadCatch m) => Socket -- ^ Listening and bound socket.- -> (forall m' . (Functor m', MonadIO m', MonadCatch m')- => SockAddr -> Socket -> m' ())+ -> (SockAddr -> Socket -> IO ()) -- ^ Computation to run in a different thread -- once an incoming connection is accepted. Takes the -- remote end address and connection socket.