yesod-form-1.7.9: Form handling support for Yesod Web Framework

Safe Haskell | None
Language | Haskell2010

Yesod.Form.Input

Description

Provides for getting input from either GET or POST params without generating HTML forms. For more information, see: http://www.yesodweb.com/book/forms#forms_kinds_of_forms.

Synopsis

- newtype FormInput (m :: Type -> Type) a = FormInput {
  - unFormInput :: HandlerSite m -> [Text] -> Env -> FileEnv -> m (Either DText a)
  }
- runInputGet :: MonadHandler m => FormInput m a -> m a
- runInputGetResult :: MonadHandler m => FormInput m a -> m (FormResult a)
- runInputPost :: MonadHandler m => FormInput m a -> m a
- runInputPostResult :: MonadHandler m => FormInput m a -> m (FormResult a)
- ireq :: forall (m :: Type -> Type) a. (Monad m, RenderMessage (HandlerSite m) FormMessage) => Field m a -> Text -> FormInput m a
- iopt :: forall (m :: Type -> Type) a. Monad m => Field m a -> Text -> FormInput m (Maybe a)

# Documentation

newtype FormInput (m :: Type -> Type) a #

Type for a form which parses a value of type `a` with the base monad `m` (usually your `Handler`). Can compose this using its `Applicative` instance.

Constructors

FormInput |

Fields

- unFormInput :: HandlerSite m -> [Text] -> Env -> FileEnv -> m (Either DText a)

#### Instances

Instances details

Monad m => Applicative (FormInput m) # |
Instance details Defined in Yesod.Form.Input Methods pure :: a -> FormInput m a # (<*>) :: FormInput m (a -> b) -> FormInput m a -> FormInput m b # liftA2 :: (a -> b -> c) -> FormInput m a -> FormInput m b -> FormInput m c # (*>) :: FormInput m a -> FormInput m b -> FormInput m b # (<*) :: FormInput m a -> FormInput m b -> FormInput m a #
Monad m => Functor (FormInput m) # |
Instance details Defined in Yesod.Form.Input Methods fmap :: (a -> b) -> FormInput m a -> FormInput m b # (<$) :: a -> FormInput m b -> FormInput m a #

runInputGet :: MonadHandler m => FormInput m a -> m a #

Run a `FormInput` on the GET parameters (i.e., query string). If parsing fails, calls `invalidArgs`.

runInputGetResult :: MonadHandler m => FormInput m a -> m (FormResult a) #

Run a `FormInput` on the GET parameters (i.e., query string). Does not throw exceptions on failure.

Since 1.4.1

runInputPost :: MonadHandler m => FormInput m a -> m a #

Run a `FormInput` on the POST parameters (i.e., request body). If parsing fails, calls `invalidArgs`.

runInputPostResult :: MonadHandler m => FormInput m a -> m (FormResult a) #

Run a `FormInput` on the POST parameters (i.e., request body). Does not throw exceptions on failure.

ireq #

Arguments

:: forall (m :: Type -> Type) a. (Monad m, RenderMessage (HandlerSite m) FormMessage) |
=> Field m a |
-> Text | name of the field
-> FormInput m a |

Promote a `Field` into a `FormInput`, requiring that the value be present and valid.

iopt :: forall (m :: Type -> Type) a. Monad m => Field m a -> Text -> FormInput m (Maybe a) #

Promote a `Field` into a `FormInput`, with its presence being optional. If the value is present but does not parse correctly, the form will still fail.