-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Simple modular utilities for CGI/FastCGI (sessions, etc.) -- -- Simple modular utilities for CGI/FastCGI that one tends to always need -- including sessions state. @package cgi-utils @version 0.1 module Network.CGI.Session -- | A session consists of a unique id and a map. data Session Session :: Integer -> Map String String -> Session sess_id :: Session -> Integer sess_values :: Session -> Map String String -- | Sessions and unique ids are stored in an MVar. type Sessions = MVar ([Integer], Map Integer Session) -- | The cookie prefix (e.g. MYHASKELLCOOKIE). type SessionName = String -- | A simple Session monad. Recommend you define your own. type SessionM = StateT Session (CGIT IO) -- | Make the sessions state. makeSessions :: IO Sessions -- | Grab the session or create a new one. initSession :: SessionName -> Sessions -> CGI Session -- | Update a session in the map. updateSession :: Sessions -> Session -> CGI () -- | Session value getter. sessionId :: SessionM Integer -- | Initialise a session state and start a F/CGI process. This is a bit of -- a pattern so I've included it here for convenience. runSessionCGI :: SessionName -> (CGI CGIResult -> IO ()) -> SessionM CGIResult -> IO () -- | Simple session runner. runSession :: Sessions -> SessionM a -> Session -> CGI a -- | Session value inserter/updater. sessionIns :: (Read a, Show a) => String -> a -> (a -> a -> a) -> SessionM () -- | Session value deleter. sessionDel :: String -> SessionM () -- | Session value getter. sessionGet :: (Read a) => String -> SessionM (Maybe a) -- | Create a new session and update the Mvar. makeSession :: SessionName -> Sessions -> CGI Session -- | Try to get the current session. getSession :: SessionName -> Sessions -> CGI (Maybe Session) instance Eq Session instance Show Session