-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Happstack support for reform.
--   
--   Reform is a library for building and validating forms using
--   applicative functors. This package add support for using reform with
--   Happstack.
@package reform-happstack
@version 0.2.5.3


-- | Support for using Reform with the Haskell Web Framework Happstack.
--   <a>http://happstack.com/</a>
module Text.Reform.Happstack

-- | create an <a>Environment</a> to be used with <a>runForm</a>
environment :: Happstack m => Environment m [Input]

-- | similar to 'eitherForm environment' but includes double-submit (Cross
--   Site Request Forgery) CSRF protection.
--   
--   The form must have been created using <a>happstackViewForm</a>
--   
--   see also: <a>happstackViewForm</a>
happstackEitherForm :: Happstack m => ([(Text, Text)] -> view -> view) -> Text -> Form m [Input] error view proof a -> m (Either view a)

-- | similar to <a>viewForm</a> but includes double-submit (Cross Site
--   Request Forgery) CSRF protection.
--   
--   Must be used with <a>happstackEitherForm</a>.
--   
--   see also: <a>happstackEitherForm</a>.
happstackViewForm :: Happstack m => ([(Text, Text)] -> view -> view) -> Text -> Form m input error view proof a -> m view

-- | Utility Function: wrap the <tt>view</tt> in a <tt>&lt;form&gt;</tt>
--   that includes double-submit CSRF protection.
--   
--   calls <a>addCSRFCookie</a> to set the cookie and adds the token as a
--   hidden field.
--   
--   see also: <a>happstackViewForm</a>, <a>happstackEitherForm</a>,
--   <a>checkCSRF</a>
happstackView :: Happstack m => ([(Text, Text)] -> view -> view) -> Text -> view -> m view

-- | Utility Function: add a cookie for CSRF protection
addCSRFCookie :: Happstack m => Text -> m Text

-- | Utility Function: get CSRF protection cookie
getCSRFCookie :: Happstack m => Text -> m Text

-- | Utility Function: check that the CSRF cookie and hidden field exist
--   and are equal
--   
--   If the check fails, this function will call:
--   
--   <pre>
--   escape $ forbidden (toResponse "CSRF check failed.")
--   </pre>
checkCSRF :: Happstack m => Text -> m ()

-- | generate the name to use for the csrf cookie
--   
--   Currently this returns the static cookie "reform-csrf". Using the
--   prefix would allow
csrfName :: Text

-- | This function allows you to embed a a single <a>Form</a> into a HTML
--   page.
--   
--   In general, you will want to use the <a>reform</a> function instead,
--   which allows more than one <a>Form</a> to be used on the same page.
--   
--   see also: <a>reform</a>
reformSingle :: (ToMessage b, Happstack m, Alternative m, Monoid view) => ([(Text, Text)] -> view -> view) -> Text -> (a -> m b) -> Maybe ([(FormRange, error)] -> view -> m b) -> Form m [Input] error view proof a -> m view

-- | this function embeds a <a>Form</a> in an HTML page.
--   
--   When the page is requested with a <a>GET</a> request, the form view
--   will be rendered.
--   
--   When the page is requested with a <a>POST</a> request, the form data
--   will be extracted and validated.
--   
--   If a value is successfully produced the success handler will be called
--   with the value.
--   
--   On failure the failure handler will be called. If no failure handler
--   is provided, then the page will simply be redisplayed. The form will
--   be rendered with the errors and previous submit data shown.
--   
--   The first argument to <a>reform</a> is a function which generates the
--   <tt>&lt;form&gt;</tt> tag. It should generally come from the template
--   library you are using, such as the <tt>form</tt> function from
--   <tt>reform-hsp</tt>.
--   
--   The <tt>[(String, String)]</tt> argument is a list of '(name, value)'
--   pairs for extra hidden fields that should be added to the
--   <tt>&lt;form&gt;</tt> tag. These hidden fields are used to provide
--   cross-site request forgery (CSRF) protection, and to support multiple
--   forms on the same page.
reform :: (ToMessage b, Happstack m, Alternative m, Monoid view) => ([(Text, Text)] -> view -> view) -> Text -> (a -> m b) -> Maybe ([(FormRange, error)] -> view -> m b) -> Form m [Input] error view proof a -> m view
instance Text.Reform.Backend.FormInput [Happstack.Server.Internal.Types.Input]
