network 2.7.0.2 → 2.8.0.0
raw patch · 6 files changed
+53/−68 lines, 6 filesdep ~base
Dependency ranges changed: base
Files
- CHANGELOG.md +11/−0
- Network/Socket.hsc +2/−2
- Network/Socket/Types.hsc +23/−48
- configure +9/−9
- configure.ac +1/−1
- network.cabal +7/−8
CHANGELOG.md view
@@ -1,3 +1,14 @@+## Version 2.8.0.0++* Breaking change: PortNumber originally contained Word32 in network+ byte order and used "deriving Ord". This results in strange behavior+ on the Ord instance. Now PortNumber holds Word32 in host byte order.+ [#347](https://github.com/haskell/network/pull/347)+* Breaking change: stopping the export of the PortNum constructor in+ PortNumber.+* Use bytestring == 0.10.* only.+* Use base >= 4.7 && < 5.+ ## Version 2.7.0.2 * Removing withMVar to avoid the deadlock between "accept" and "close"
Network/Socket.hsc view
@@ -167,7 +167,7 @@ # endif #endif -- ** Port number- , PortNumber(..)+ , PortNumber , defaultPort , socketPortSafe , socketPort@@ -262,7 +262,7 @@ import Foreign.Marshal.Utils ( maybeWith, with ) import System.IO-import Control.Monad (liftM, when)+import Control.Monad (liftM, when, void) import qualified Control.Exception as E import Control.Concurrent.MVar
Network/Socket/Types.hsc view
@@ -1,6 +1,7 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ForeignFunctionInterface #-}+{-# LANGUAGE GeneralizedNewtypeDeriving #-} #include "HsNet.h" ##include "HsNetDef.h"@@ -63,7 +64,6 @@ import Control.Monad import Data.Bits import Data.Maybe-import Data.Ratio import Data.Typeable import Data.Word import Data.Int@@ -746,65 +746,40 @@ -- Port Numbers -- | Use the @Num@ instance (i.e. use a literal) to create a--- @PortNumber@ value with the correct network-byte-ordering. You--- should not use the PortNum constructor. It will be removed in the--- next release.+-- @PortNumber@ value. -- -- >>> 1 :: PortNumber -- 1 -- >>> read "1" :: PortNumber -- 1-newtype PortNumber = PortNum Word16 deriving (Eq, Ord, Typeable)--- newtyped to prevent accidental use of sane-looking--- port numbers that haven't actually been converted to--- network-byte-order first.--{-# DEPRECATED PortNum "Do not use the PortNum constructor. Use the Num instance. PortNum will be removed in the next release." #-}+-- >>> show (12345 :: PortNumber)+-- "12345"+-- >>> 50000 < (51000 :: PortNumber)+-- True+-- >>> 50000 < (52000 :: PortNumber)+-- True+-- >>> 50000 + (10000 :: PortNumber)+-- 60000+newtype PortNumber = PortNum Word16 deriving (Eq, Ord, Typeable, Num, Enum, Real, Integral) +-- Print "n" instead of "PortNum n". instance Show PortNumber where- showsPrec p pn = showsPrec p (portNumberToInt pn)+ showsPrec p (PortNum pn) = showsPrec p (fromIntegral pn :: Int) +-- Read "n" instead of "PortNum n". instance Read PortNumber where- readsPrec n = map (\(x,y) -> (intToPortNumber x, y)) . readsPrec n--intToPortNumber :: Int -> PortNumber-intToPortNumber v = PortNum (htons (fromIntegral v))--portNumberToInt :: PortNumber -> Int-portNumberToInt (PortNum po) = fromIntegral (ntohs po)+ readsPrec n = map (\(x,y) -> (fromIntegral (x :: Int), y)) . readsPrec n foreign import CALLCONV unsafe "ntohs" ntohs :: Word16 -> Word16 foreign import CALLCONV unsafe "htons" htons :: Word16 -> Word16 foreign import CALLCONV unsafe "ntohl" ntohl :: Word32 -> Word32 foreign import CALLCONV unsafe "htonl" htonl :: Word32 -> Word32 -instance Enum PortNumber where- toEnum = intToPortNumber- fromEnum = portNumberToInt--instance Num PortNumber where- fromInteger i = intToPortNumber (fromInteger i)- -- for completeness.- (+) x y = intToPortNumber (portNumberToInt x + portNumberToInt y)- (-) x y = intToPortNumber (portNumberToInt x - portNumberToInt y)- negate x = intToPortNumber (-portNumberToInt x)- (*) x y = intToPortNumber (portNumberToInt x * portNumberToInt y)- abs n = intToPortNumber (abs (portNumberToInt n))- signum n = intToPortNumber (signum (portNumberToInt n))--instance Real PortNumber where- toRational x = toInteger x % 1--instance Integral PortNumber where- quotRem a b = let (c,d) = quotRem (portNumberToInt a) (portNumberToInt b) in- (intToPortNumber c, intToPortNumber d)- toInteger a = toInteger (portNumberToInt a)- instance Storable PortNumber where sizeOf _ = sizeOf (undefined :: Word16) alignment _ = alignment (undefined :: Word16)- poke p (PortNum po) = poke (castPtr p) po- peek p = PortNum `liftM` peek (castPtr p)+ poke p (PortNum po) = poke (castPtr p) (htons po)+ peek p = (PortNum . ntohs) `liftM` peek (castPtr p) ------------------------------------------------------------------------ -- Socket addresses@@ -836,10 +811,10 @@ -- 'isSupportedSockAddr'. data SockAddr -- C Names = SockAddrInet- PortNumber -- sin_port (network byte order)+ PortNumber -- sin_port HostAddress -- sin_addr (ditto) | SockAddrInet6- PortNumber -- sin6_port (network byte order)+ PortNumber -- sin6_port FlowInfo -- sin6_flowinfo (ditto) HostAddress6 -- sin6_addr (ditto) ScopeID -- sin6_scope_id (ditto)@@ -957,7 +932,7 @@ poker = case path of ('\0':_) -> pokeArray; _ -> pokeArray0 0 poker ((#ptr struct sockaddr_un, sun_path) p) pathC #endif-pokeSockAddr p (SockAddrInet (PortNum port) addr) = do+pokeSockAddr p (SockAddrInet port addr) = do #if defined(darwin_HOST_OS) zeroMemory p (#const sizeof(struct sockaddr_in)) #endif@@ -968,7 +943,7 @@ (#poke struct sockaddr_in, sin_port) p port (#poke struct sockaddr_in, sin_addr) p addr #if defined(IPV6_SOCKET_SUPPORT)-pokeSockAddr p (SockAddrInet6 (PortNum port) flow addr scope) = do+pokeSockAddr p (SockAddrInet6 port flow addr scope) = do #if defined(darwin_HOST_OS) zeroMemory p (#const sizeof(struct sockaddr_in6)) #endif@@ -1006,14 +981,14 @@ (#const AF_INET) -> do addr <- (#peek struct sockaddr_in, sin_addr) p port <- (#peek struct sockaddr_in, sin_port) p- return (SockAddrInet (PortNum port) addr)+ return (SockAddrInet port addr) #if defined(IPV6_SOCKET_SUPPORT) (#const AF_INET6) -> do port <- (#peek struct sockaddr_in6, sin6_port) p flow <- (#peek struct sockaddr_in6, sin6_flowinfo) p In6Addr addr <- (#peek struct sockaddr_in6, sin6_addr) p scope <- (#peek struct sockaddr_in6, sin6_scope_id) p- return (SockAddrInet6 (PortNum port) flow addr scope)+ return (SockAddrInet6 port flow addr scope) #endif #if defined(CAN_SOCKET_SUPPORT) (#const AF_CAN) -> do
configure view
@@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles.-# Generated by GNU Autoconf 2.69 for Haskell network package 2.6.3.5.+# Generated by GNU Autoconf 2.69 for Haskell network package 2.6.3.1. # # Report bugs to <libraries@haskell.org>. #@@ -580,8 +580,8 @@ # Identity of this package. PACKAGE_NAME='Haskell network package' PACKAGE_TARNAME='network'-PACKAGE_VERSION='2.6.3.5'-PACKAGE_STRING='Haskell network package 2.6.3.5'+PACKAGE_VERSION='2.6.3.1'+PACKAGE_STRING='Haskell network package 2.6.3.1' PACKAGE_BUGREPORT='libraries@haskell.org' PACKAGE_URL='' @@ -1249,7 +1249,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF-\`configure' configures Haskell network package 2.6.3.5 to adapt to many kinds of systems.+\`configure' configures Haskell network package 2.6.3.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1315,7 +1315,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in- short | recursive ) echo "Configuration of Haskell network package 2.6.3.5:";;+ short | recursive ) echo "Configuration of Haskell network package 2.6.3.1:";; esac cat <<\_ACEOF @@ -1400,7 +1400,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF-Haskell network package configure 2.6.3.5+Haskell network package configure 2.6.3.1 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc.@@ -1872,7 +1872,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by Haskell network package $as_me 2.6.3.5, which was+It was created by Haskell network package $as_me 2.6.3.1, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@@@ -4621,7 +4621,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log="-This file was extended by Haskell network package $as_me 2.6.3.5, which was+This file was extended by Haskell network package $as_me 2.6.3.1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES@@ -4683,7 +4683,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\-Haskell network package config.status 2.6.3.5+Haskell network package config.status 2.6.3.1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\"
configure.ac view
@@ -1,4 +1,4 @@-AC_INIT([Haskell network package], [2.7.0.2], [libraries@haskell.org], [network])+AC_INIT([Haskell network package], [2.8.0.0], [libraries@haskell.org], [network]) ac_includes_default="$ac_includes_default #ifdef HAVE_SYS_SOCKET_H
network.cabal view
@@ -1,5 +1,5 @@ name: network-version: 2.7.0.2+version: 2.8.0.0 license: BSD3 license-file: LICENSE maintainer: Kazu Yamamoto, Evan Borden@@ -30,12 +30,11 @@ cbits/winSockErr.c homepage: https://github.com/haskell/network bug-reports: https://github.com/haskell/network/issues-tested-with: GHC == 7.4.2- , GHC == 7.6.3- , GHC == 7.8.4+tested-with: GHC == 7.8.4 , GHC == 7.10.3 , GHC == 8.0.2 , GHC == 8.2.2+ , GHC == 8.4.3 library exposed-modules:@@ -59,8 +58,8 @@ Network.Socket.ByteString.Lazy.Windows build-depends:- base >= 4.6 && < 5,- bytestring < 0.11+ base >= 4.7 && < 5,+ bytestring == 0.10.* if !os(windows) build-depends:@@ -82,7 +81,7 @@ type: exitcode-stdio-1.0 ghc-options: -Wall -threaded build-depends:- base < 5,+ base >= 4.7 && < 5, bytestring, directory, HUnit,@@ -95,7 +94,7 @@ type: exitcode-stdio-1.0 build-depends:- base < 5,+ base >= 4.7 && < 5, doctest >= 0.10.1 ghc-options: -Wall