-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Compose network transports
--   
--   Compose network transports
@package network-transport-composed
@version 0.2.1


-- | Combine two transports into a single new transport
--   
--   Given two transports A and B, endpoints in the combined transport are
--   pairs of endpoints for the underlying transports. Consequently, the
--   address of an endpoint in the combined transport is a pair of
--   addresses of the two underlying endpoints. Events from both underlying
--   endpoints are posted to the combined endpoint.
--   
--   When the address of combined endpoint C1 is sent to combined endpoint
--   C2, and C2 attempts to make a connection to C1, it needs to choice an
--   underlying endpoint to make the connection. The choice is made by a
--   parameter <a>resolveAddress</a> of the composed transport.
--   
--   When C2 connects to C1 then it is assumed that whatever transport C2
--   uses to connect to C1, this is the same transport that C1 needs to use
--   to connect back to C2.
--   
--   TODO: at the moment the address reported by a ConnectionOpened might
--   differ from the address reported by the remote endpoint itself. This
--   might cause difficulties?
module Network.Transport.Composed
data ComposedTransport
ComposedTransport :: Transport -> Transport -> ((EndPoint, EndPoint) -> (EndPointAddress, EndPointAddress) -> IO (EndPoint, EndPointAddress)) -> ComposedTransport

-- | The left transport
[transportA] :: ComposedTransport -> Transport

-- | The right transport
[transportB] :: ComposedTransport -> Transport

-- | Pick a suitable transport for an address
[resolveAddress] :: ComposedTransport -> (EndPoint, EndPoint) -> (EndPointAddress, EndPointAddress) -> IO (EndPoint, EndPointAddress)
createTransport :: ComposedTransport -> IO Transport
