Skip to content

Commit

Permalink
Merge pull request #20 from larskuhtz/network-3
Browse files Browse the repository at this point in the history
support network >= 3.0.0
  • Loading branch information
creichert authored Jun 18, 2019
2 parents 7a8095a + 022eca5 commit eece473
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Network/Wai/Middleware/Throttle/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Data.Hashable (Hashable, hashWithSalt)
import GHC.Word (Word64)
import Network.HTTP.Types.Status (status429)
import Network.Socket (SockAddr (SockAddrInet, SockAddrInet6, SockAddrUnix))
#if MIN_VERSION_network(2,6,1)
#if MIN_VERSION_network(2,6,1) && ! MIN_VERSION_network(3,0,0)
import Network.Socket (SockAddr (SockAddrCan))
#endif
import Network.Wai (Application, Request, Response, remoteHost, responseLBS)
Expand All @@ -26,15 +26,15 @@ instance Hashable Address where
hashWithSalt s (Address (SockAddrInet _ a)) = hashWithSalt s a
hashWithSalt s (Address (SockAddrInet6 _ _ a _)) = hashWithSalt s a
hashWithSalt s (Address (SockAddrUnix a)) = hashWithSalt s a
#if MIN_VERSION_network(2,6,1)
#if MIN_VERSION_network(2,6,1) && ! MIN_VERSION_network(3,0,0)
hashWithSalt s (Address (SockAddrCan a)) = hashWithSalt s a
#endif

instance Eq Address where
Address (SockAddrInet _ a) == Address (SockAddrInet _ b) = a == b
Address (SockAddrInet6 _ _ a _) == Address (SockAddrInet6 _ _ b _) = a == b
Address (SockAddrUnix a) == Address (SockAddrUnix b) = a == b
#if MIN_VERSION_network(2,6,1)
#if MIN_VERSION_network(2,6,1) && ! MIN_VERSION_network(3,0,0)
Address (SockAddrCan a) == Address (SockAddrCan b) = a == b
#endif
_ == _ = False -- not same constructor so cant be equal
Expand All @@ -43,7 +43,7 @@ instance Ord Address where
Address (SockAddrInet _ a) <= Address (SockAddrInet _ b) = a <= b
Address (SockAddrInet6 _ _ a _) <= Address (SockAddrInet6 _ _ b _) = a <= b
Address (SockAddrUnix a) <= Address (SockAddrUnix b) = a <= b
#if MIN_VERSION_network(2,6,1)
#if MIN_VERSION_network(2,6,1) && ! MIN_VERSION_network(3,0,0)
Address (SockAddrCan a) <= Address (SockAddrCan b) = a <= b
#endif
Address a <= Address b = a <= b -- not same constructor so use builtin ordering
Expand Down

0 comments on commit eece473

Please sign in to comment.