-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Continuation based web programming for Happstack -- -- WebCont allows continuation based web programming to be integrated -- with Happstack, allowing step based interfaces along with traditional -- handlers. It is based on http://gist.github.com/260052 @package WebCont @version 0.0.1 -- | WebConts allow simple continuation based behavior in Happstack -- applications through the use of cookies and an IntMap on the server -- mapping cookie names to continuations. It is based on the paste -- http://gist.github.com/260052. For the arc challenge: -- --
-- arc = do -- name <- doform' frm -- display $ samelink "click here" -- display $ "you said" ++ name ---- -- A more complicated example, creating a User datatype with a different -- page for each field: -- --
-- data User = User {age:: Int, name::String, dead::Bool} deriving (Show)
-- makeUser = liftM3 User age name dead >>= (display . show) where
-- age = doform' $ label "Age: " *> frm
-- name = doform' $ label "Name: " *> frm
-- dead = doform' $ label "Dead?: " *> frm
--
--
-- To run the continuations in Happstack, use runStateless or
-- runWithState, giving each continuation in a list as a
-- parameter, depending on whether you want MACID support enabled:
--
-- -- runStateless nullConf [arc, makeUser] [] --module WebCont -- | Lift a form into the WebCont monad using a function doform :: (Html -> r) -> ([String] -> Html -> r) -> ContForm a -> WebCont r a -- | Lift a form into the WebCont monad without embellishment, displaying -- errors inline doform' :: ContForm a -> WebCont Html a -- | Entry point for the continuation server: sets up continuation table, -- MACID state, and a chron job to add a checkpoint daily runWithState :: (Methods a, Component a) => Conf -> Proxy a -> [WebCont Html ()] -> [ServerPartT IO Response] -> IO () -- | Entry point for the continuation server: starts the server without -- MACID support runStateless :: Conf -> [WebCont Html ()] -> [ServerPartT IO Response] -> IO () -- | Display a page, ignoring the value display :: (HTML a) => a -> WebCont Html () -- | Links to the same page, leading to the next step in a continuation samelink :: (HTML a) => a -> HotLink -- | Button with an associated value button :: String -> a -> WebCont Html a -- | Link with an associated value link :: (HTML l) => l -> a -> WebCont Html a -- | A WebCont is a function from Env to a value of a, displaying a -- response of r. Both r and a must be Html for runnable continuations. newtype WebCont r a WebCont :: (Env -> Result r a) -> WebCont r a runWeb :: WebCont r a -> Env -> Result r a data Result r a Done :: a -> Result r a Via :: r -> (WebCont r a) -> Result r a type ContForm a = XHtmlForm Identity a -- | Defines a normal form style to use for a given type class DefaultForm i frm :: (DefaultForm i) => Form Html Identity i -- | Default configuration contains no validator and the port is set to -- 8000 nullConf :: Conf instance Show (WebCont r a) instance (Show r, Show a) => Show (Result r a) instance Applicative Identity instance HTML Integer instance (DefaultForm a, DefaultForm b) => DefaultForm (a, b) instance DefaultForm Bool instance DefaultForm Int instance DefaultForm Integer instance DefaultForm String instance (Monoid r, Monoid a) => Monoid (WebCont r a) instance (Monoid a) => Monoid (WebCont a a) instance Monad (WebCont r)