X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Lucu.git;a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FSocketLike.hs;h=dd9c34b00fc54935c051e4dd560cc123a7c28402;hp=915f32376eb17a3ae6a57eef443648698bc4d63b;hb=0aa4f6d;hpb=8225cc52ffe4c3d900ae1f79573089be230b80bd diff --git a/Network/HTTP/Lucu/SocketLike.hs b/Network/HTTP/Lucu/SocketLike.hs index 915f323..dd9c34b 100644 --- a/Network/HTTP/Lucu/SocketLike.hs +++ b/Network/HTTP/Lucu/SocketLike.hs @@ -8,37 +8,34 @@ module Network.HTTP.Lucu.SocketLike ( SocketLike(..) ) where - import qualified Network.Socket as So -import Network.HTTP.Lucu.HandleLike +import Network.HTTP.Lucu.HandleLike import qualified OpenSSL.Session as SSL +import Prelude.Unicode import qualified System.IO as I - -class (HandleLike (Handle s)) => SocketLike s where - type Handle s :: * - accept :: s -> IO (Handle s, So.SockAddr) - socketPort :: s -> IO So.PortNumber - +class (HandleLike (Handle s)) ⇒ SocketLike s where + type Handle s ∷ ★ + accept ∷ s → IO (Handle s, So.SockAddr) + socketPort ∷ s → IO So.PortNumber instance SocketLike So.Socket where type Handle So.Socket = I.Handle accept soSelf - = do (soPeer, addr) <- So.accept soSelf - hPeer <- So.socketToHandle soPeer I.ReadWriteMode + = do (soPeer, addr) ← So.accept soSelf + hPeer ← So.socketToHandle soPeer I.ReadWriteMode return (hPeer, addr) socketPort = So.socketPort - instance SocketLike (SSL.SSLContext, So.Socket) where type Handle (SSL.SSLContext, So.Socket) = SSL.SSL accept (ctx, soSelf) - = do (soPeer, addr) <- So.accept soSelf - ssl <- SSL.connection ctx soPeer + = do (soPeer, addr) ← So.accept soSelf + ssl ← SSL.connection ctx soPeer SSL.accept ssl return (ssl, addr) - socketPort = So.socketPort . snd \ No newline at end of file + socketPort = So.socketPort ∘ snd