]> code.delx.au - offlineimap/commitdiff
Added IMAPState to clean up readability
authorJohn Goerzen <jgoerzen@complete.org>
Mon, 11 Aug 2008 10:57:15 +0000 (05:57 -0500)
committerJohn Goerzen <jgoerzen@complete.org>
Mon, 11 Aug 2008 10:57:15 +0000 (05:57 -0500)
src/Network/IMAP/Connection.hs

index bd1b4547dad4d799e32400460f60092c5b3dfcb3..17fd82f83ebe8ce55b8026424c87837e7799d180 100644 (file)
@@ -22,6 +22,8 @@ import Control.Monad.State
 import Data.List.Utils(spanList)
 import Data.List(genericSplitAt, genericLength)
 
+type IMAPState = State (IMAPString, IMAPString)
+
 {- | Set up an IMAPConnection that runs in the State monad.
 
 The state is (bufferToClient, bufferFromClient)
@@ -29,7 +31,7 @@ The state is (bufferToClient, bufferFromClient)
 Remember that EOL in IMAP protocols is \r\n!
 
 closeConnection is ignored with this monad. -}
-newStringConnection :: IMAPConnection (State (IMAPString, IMAPString))
+newStringConnection :: IMAPConnection IMAPState
 newStringConnection =
     IMAPConnection {readBytes = lreadBytes,
                     readLine = lreadLine,
@@ -57,15 +59,9 @@ newStringConnection =
 
 {- | Runs a State monad with a String connection.  Returns
 (retval, remainingBufferToClient, bufferFromClient) -}
-{-
-runStringConnection :: 
-    IMAPString -> 
-    ((State s a) -> a) ->
-    (a, IMAPString, IMAPString)
--}
 runStringConnection ::
        IMAPString               -- ^ Buffer to send to clients
-    -> (IMAPConnection (State (IMAPString, IMAPString)) -> State (IMAPString, IMAPString) a) -- ^ Function to run
+    -> (IMAPConnection IMAPState -> IMAPState a) -- ^ Function to run
     -> (a, (String, String))    -- ^ Results: func result, buffer status
 runStringConnection sbuf func =
     runState (func newStringConnection) (sbuf::String, []::String)