IMAP specs and typing
IMAP, Internet Message Access Protocol, is a fairly complecated protocol (comparing with POP3). Its specification can be read as RFC 3501.
I worry about the typing of IMAP commands. In normal protocol, the type of a client command can be written such as `Connection -> Request -> IO Response'. However, IMAP server may also return a status update data.
The server program can notify its clients with a status update untagged data. Assume that there is a client connecting to a server and the server may receive a new mail during the connection, for example. In normal, such newly received mail cannot be read from the client because the connection is established before the reception of the mail. However, the server may notify the client as that `it has a new mail'. Any commands may have such status update data.
Therefore, the type of a IMAP command should be `Connection -> Request -> IO (Response, Maybe StatusUpate)', but such typing will be annoying in many case...
Certainly, such typing can be hidden with StateT or WriterT. But is it clever approach?
BTW, I test the behavior of IMAP with Courier-IMAP, an implementation of IMAP, but it will not send any status update data with a command except NOOP. mmm....