cgi-3001.3.0.3: A library for writing CGI programs

Copyright(c) Bjorn Bringert 2006
LicenseBSD-style
MaintainerJohn Chee <cheecheeo@gmail.com>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell98

Network.CGI.Monad

Contents

Description

Internal stuff that most people shouldn't have to use. This module mostly deals with the internals of the CGIT monad transformer.

Synopsis

CGI monad class

class Monad m => MonadCGI m where Source #

The class of CGI monads. Most CGI actions can be run in any monad which is an instance of this class, which means that you can use your own monad transformers to add extra functionality.

Methods

cgiAddHeader :: HeaderName -> String -> m () Source #

Add a response header.

cgiGet :: (CGIRequest -> a) -> m a Source #

Get something from the CGI request.

Instances
Monad m => MonadCGI (CGIT m) Source # 
Instance details

Defined in Network.CGI.Monad

Methods

cgiAddHeader :: HeaderName -> String -> CGIT m () Source #

cgiGet :: (CGIRequest -> a) -> CGIT m a Source #

CGI monad transformer

newtype CGIT m a Source #

The CGIT monad transformer.

Constructors

CGIT 
Instances
MonadTrans CGIT Source # 
Instance details

Defined in Network.CGI.Monad

Methods

lift :: Monad m => m a -> CGIT m a #

MonadCatch m => MonadError SomeException (CGIT m) Source # 
Instance details

Defined in Network.CGI.Monad

Methods

throwError :: SomeException -> CGIT m a #

catchError :: CGIT m a -> (SomeException -> CGIT m a) -> CGIT m a #

Monad m => Monad (CGIT m) Source # 
Instance details

Defined in Network.CGI.Monad

Methods

(>>=) :: CGIT m a -> (a -> CGIT m b) -> CGIT m b #

(>>) :: CGIT m a -> CGIT m b -> CGIT m b #

return :: a -> CGIT m a #

fail :: String -> CGIT m a #

Functor m => Functor (CGIT m) Source # 
Instance details

Defined in Network.CGI.Monad

Methods

fmap :: (a -> b) -> CGIT m a -> CGIT m b #

(<$) :: a -> CGIT m b -> CGIT m a #

Applicative m => Applicative (CGIT m) Source # 
Instance details

Defined in Network.CGI.Monad

Methods

pure :: a -> CGIT m a #

(<*>) :: CGIT m (a -> b) -> CGIT m a -> CGIT m b #

liftA2 :: (a -> b -> c) -> CGIT m a -> CGIT m b -> CGIT m c #

(*>) :: CGIT m a -> CGIT m b -> CGIT m b #

(<*) :: CGIT m a -> CGIT m b -> CGIT m a #

MonadIO m => MonadIO (CGIT m) Source # 
Instance details

Defined in Network.CGI.Monad

Methods

liftIO :: IO a -> CGIT m a #

MonadThrow m => MonadThrow (CGIT m) Source # 
Instance details

Defined in Network.CGI.Monad

Methods

throwM :: Exception e => e -> CGIT m a #

MonadCatch m => MonadCatch (CGIT m) Source # 
Instance details

Defined in Network.CGI.Monad

Methods

catch :: Exception e => CGIT m a -> (e -> CGIT m a) -> CGIT m a #

MonadMask m => MonadMask (CGIT m) Source # 
Instance details

Defined in Network.CGI.Monad

Methods

mask :: ((forall a. CGIT m a -> CGIT m a) -> CGIT m b) -> CGIT m b #

uninterruptibleMask :: ((forall a. CGIT m a -> CGIT m a) -> CGIT m b) -> CGIT m b #

generalBracket :: CGIT m a -> (a -> ExitCase b -> CGIT m c) -> (a -> CGIT m b) -> CGIT m (b, c) #

Monad m => MonadCGI (CGIT m) Source # 
Instance details

Defined in Network.CGI.Monad

Methods

cgiAddHeader :: HeaderName -> String -> CGIT m () Source #

cgiGet :: (CGIRequest -> a) -> CGIT m a Source #

type CGI a = CGIT IO a Source #

A simple CGI monad with just IO.

runCGIT :: Monad m => CGIT m a -> CGIRequest -> m (Headers, a) Source #

Run a CGI action.

Request info

data CGIRequest Source #

The input to a CGI action.

Constructors

CGIRequest 

Fields

  • cgiVars :: Map String String

    Environment variables.

  • cgiInputs :: [(String, Input)]

    Input parameters. For better laziness in reading inputs, this is not a Map.

  • cgiRequestBody :: ByteString

    Raw request body. To avoid memory leaks, this is the empty string if the request body has been interpreted as inputs in "application/x-www-form-urlencoded" or "multipart/form-data" format.

Instances
Show CGIRequest Source # 
Instance details

Defined in Network.CGI.Protocol

Error handling

throwCGI :: (MonadCGI m, MonadThrow m) => SomeException -> m a Source #

Throw an exception in a CGI monad. The monad is required to be a MonadThrow, so that we can use throwM to guarantee ordering.

catchCGI :: (MonadCGI m, MonadCatch m) => m a -> (SomeException -> m a) -> m a Source #

Catches any expection thrown by a CGI action, and uses the given exception handler if an exception is thrown.

tryCGI :: (Functor m, MonadCGI m, MonadCatch m) => m a -> m (Either SomeException a) Source #

Catches any exception thrown by an CGI action, and returns either the exception, or if no exception was raised, the result of the action.

handleExceptionCGI :: (MonadCGI m, MonadCatch m) => m a -> (SomeException -> m a) -> m a Source #

Deprecated: Use catchCGI instead.

Deprecated version of catchCGI. Use catchCGI instead.