import public Data.Either
import public Data.Maybe
import public Network.Socket.Data
data SocketState : Type
data Action : SocketState -> Type
Define the domain of SocketState transitions.
Label every such transition.
data Socket : SocketState -> Type
Next : Action st -> Bool -> Type
For every label of a SocketState transition
and a success value of the transition,
define its result.
newSocket : LinearIO io => SocketFamily -> SocketType -> ProtocolNumber -> ((1 _ : Socket Ready) -> L io ()) -> (SocketError -> L io ()) -> L io ()
close : LinearIO io => (1 _ : Socket st) -> L1 io (Socket Closed)
done : LinearIO io => (1 _ : Socket Closed) -> L io ()
bind : LinearIO io => (1 _ : Socket Ready) -> Maybe SocketAddress -> Port -> L1 io (Res (Maybe SocketError) (\res => Next Bind (isNothing res)))
connect : LinearIO io => (1 _ : Socket Ready) -> SocketAddress -> Port -> L1 io (Res (Maybe SocketError) (\res => Next Connect (isNothing res)))
listen : LinearIO io => (1 _ : Socket Bound) -> L1 io (Res (Maybe SocketError) (\res => Next Listen (isNothing res)))
accept : LinearIO io => (1 _ : Socket Listening) -> L1 io (Res (Maybe SocketError) (\res => Next Accept (isNothing res)))
send : LinearIO io => (1 _ : Socket Open) -> String -> L1 io (Res (Maybe SocketError) (\res => Next Send (isNothing res)))
recv : LinearIO io => (1 _ : Socket Open) -> ByteLength -> L1 io (Res (Either SocketError (String, ResultCode)) (\res => Next Receive (isRight res)))
recvAll : LinearIO io => (1 _ : Socket Open) -> L1 io (Res (Either SocketError String) (\res => Next Receive (isRight res)))
sendBytes : LinearIO io => (1 _ : Socket Open) -> List Bits8 -> L1 io (Res (Maybe SocketError) (\res => Next Send (isNothing res)))
recvBytes : LinearIO io => (1 _ : Socket Open) -> ByteLength -> L1 io (Res (Either SocketError (List Bits8)) (\res => Next Receive (isRight res)))
recvAllBytes : LinearIO io => (1 _ : Socket Open) -> L1 io (Res (Either SocketError (List Bits8)) (\res => Next Receive (isRight res)))