Skip to content

Commit

Permalink
ConnectionId: changed Ord instance
Browse files Browse the repository at this point in the history
Order first by `remoteAddress`, then by `localAddress`.
  • Loading branch information
coot committed Apr 23, 2024
1 parent b920924 commit 23f151a
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,17 @@ data ConnectionId addr = ConnectionId {
localAddress :: !addr,
remoteAddress :: !addr
}
deriving (Eq, Ord, Show, Generic)
deriving (Eq, Show, Generic)
deriving NoThunks via InspectHeap (ConnectionId addr)
deriving Functor

-- | Order first by `remoteAddress` then by `localAddress`.
--
instance Ord addr => Ord (ConnectionId addr) where
conn `compare` conn' =
remoteAddress conn `compare` remoteAddress conn'
<> localAddress conn `compare` localAddress conn'

instance Hashable a => Hashable (ConnectionId a)

instance forall addr. ShowProxy addr => ShowProxy (ConnectionId addr) where
Expand Down

0 comments on commit 23f151a

Please sign in to comment.