Skip to content

Commit

Permalink
snocket: Accept swap type parameters
Browse files Browse the repository at this point in the history
This makes 'Accept' consistent with 'Snocket.
  • Loading branch information
coot authored and newhoggy committed Nov 23, 2020
1 parent d172c4a commit f7d522f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions ouroboros-network-framework/src/Ouroboros/Network/Snocket.hs
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,21 @@ import Ouroboros.Network.IOManager
-- created by 'open' and only subsequent calls will create a new file
-- descriptor by `createNamedPipe`, see 'namedPipeSnocket'.
--
newtype Accept m addr fd = Accept
{ runAccept :: m (fd, addr, Accept m addr fd)
newtype Accept m fd addr = Accept
{ runAccept :: m (fd, addr, Accept m fd addr)
}

instance Functor m => Bifunctor (Accept m) where
bimap f g ac = Accept $ h <$> runAccept ac
where
h (fd, addr, next) = (g fd, f addr, bimap f g next)
h (fd, addr, next) = (f fd, g addr, bimap f g next)


-- | BSD accept loop.
--
berkeleyAccept :: IOManager
-> Socket
-> Accept IO SockAddr Socket
-> Accept IO Socket SockAddr
berkeleyAccept ioManager sock = go
where
go = Accept $ do
Expand Down Expand Up @@ -181,7 +181,7 @@ data Snocket m fd addr = Snocket {
, bind :: fd -> addr -> m ()
, listen :: fd -> m ()

, accept :: fd -> Accept m addr fd
, accept :: fd -> Accept m fd addr

, close :: fd -> m ()

Expand Down Expand Up @@ -346,7 +346,7 @@ localSnocket ioManager path = Snocket {
localAddress :: LocalAddress
localAddress = LocalAddress path

acceptNext :: Accept IO LocalAddress LocalSocket
acceptNext :: Accept IO LocalSocket LocalAddress
acceptNext = Accept $ do
hpipe <- Win32.createNamedPipe
path
Expand All @@ -373,7 +373,7 @@ localSnocket ioManager _ =
Socket.connect s (fromLocalAddress addr)
, bind = \(LocalSocket fd) addr -> Socket.bind fd (fromLocalAddress addr)
, listen = flip Socket.listen 1 . getLocalHandle
, accept = bimap toLocalAddress LocalSocket
, accept = bimap LocalSocket toLocalAddress
. berkeleyAccept ioManager
. getLocalHandle
, open = openSocket
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ fromSnocket
-> Server.Socket addr fd
fromSnocket tblVar sn sd = go (Snocket.accept sn sd)
where
go :: Snocket.Accept IO addr fd -> Server.Socket addr fd
go :: Snocket.Accept IO fd addr -> Server.Socket addr fd
go (Snocket.Accept accept) = Server.Socket $ do
(sd', remoteAddr, next) <- accept
-- TOOD: we don't need to that on each accept
Expand Down

0 comments on commit f7d522f

Please sign in to comment.