Skip to content

Instantly share code, notes, and snippets.

@robstewart57
Last active December 14, 2015 11:49
Show Gist options
  • Save robstewart57/5081439 to your computer and use it in GitHub Desktop.
Save robstewart57/5081439 to your computer and use it in GitHub Desktop.
-- API Module: Transport API as typeclass
class Transport t where
createTransport :: IO (Either IOException t)
newEndPoint :: t -> IO (Either (TransportError NewEndPointErrorCode) EndPoint)
closeTransport :: t -> IO ()
-- Separate module: TCP implementation
newtype TCPTransport = TCPTransport (N.HostName,N.ServiceName,MVar TransportState,TCPParameters)
instance Transport TCPTransport where
createTransport = mkTCPTransport
newEndPoint tcp = mkTCPEndPoint tcp
closeTransport tcp = closeTCPTransport tcp
mkTCPTransport = -- blah
mkTCPEndPoint (TCPTransport (host,service,state,params)) = -- blah
closeTCPTransport (TCPTransport (host,service,state,params)) = -- blah
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment