Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- newtype FormData a = FormData {
- getFormData :: HashMap Text [Text]
- class FormError input err where
- commonFormError :: CommonFormError input -> err
- newtype TrasaFormT m a = TrasaFormT {
- getTrasaFormT :: ReaderT FormType (TrasaT m) a
- data FormType
- type TrasaForm a = Form (TrasaFormT IO) QueryParam TrasaFormError (Html ()) a
- data TrasaFormError = TrasaFormError {}
- bodyFormData :: BodyCodec (FormData a)
- liftParser :: (Text -> Either Text a) -> QueryParam -> Either TrasaFormError a
- liftToForm :: Monad m => TrasaT m a -> TrasaFormT m a
- reform :: (MonadIO m, Monoid view) => ([(Text, Text)] -> view -> view) -> Text -> Form (TrasaFormT m) QueryParam err view a -> TrasaT m (Result err a, view)
- reformPost :: (MonadIO m, Monoid view) => ([(Text, Text)] -> view -> view) -> Text -> Maybe (FormData a) -> Form (TrasaFormT m) QueryParam err view a -> TrasaT m (Result err a, view)
- trasaFormView :: Monad m => Text -> Form (TrasaFormT m) QueryParam err view a -> TrasaT m view
- textError :: Text -> TrasaFormError
Documentation
FormData | |
|
Instances
Eq (FormData a) Source # | |
Ord (FormData a) Source # | |
Show (FormData a) Source # | |
Semigroup (FormData a) Source # | |
Monoid (FormData a) Source # | |
class FormError input err where #
A Class to lift a CommonFormError
into an application-specific error type
commonFormError :: CommonFormError input -> err #
Instances
FormError Text Text | |
Defined in Ditto.Backend commonFormError :: CommonFormError Text -> Text # | |
FormError QueryParam TrasaFormError Source # | |
Defined in Trasa.Form |
newtype TrasaFormT m a Source #
a newtype over TrasaT which allows it to have
different environments for GET
and POST
requests
TrasaFormT | |
|
Instances
a GET request, or a POST
request which may hav the untyped FormData
Instances
Monad m => MonadReader FormType (TrasaFormT m) Source # | |
Defined in Trasa.Form ask :: TrasaFormT m FormType # local :: (FormType -> FormType) -> TrasaFormT m a -> TrasaFormT m a # reader :: (FormType -> a) -> TrasaFormT m a # |
type TrasaForm a = Form (TrasaFormT IO) QueryParam TrasaFormError (Html ()) a Source #
a type alias for the most common type of form using trasa-form
data TrasaFormError Source #
trasa-form
's form error type: may have a CommonFormError
, will have an error message
Instances
Show TrasaFormError Source # | |
Defined in Trasa.Form showsPrec :: Int -> TrasaFormError -> ShowS # show :: TrasaFormError -> String # showList :: [TrasaFormError] -> ShowS # | |
IsString TrasaFormError Source # | |
Defined in Trasa.Form fromString :: String -> TrasaFormError # | |
ToHtml TrasaFormError Source # | |
Defined in Trasa.Form toHtml :: Monad m => TrasaFormError -> HtmlT m () # toHtmlRaw :: Monad m => TrasaFormError -> HtmlT m () # | |
FormError QueryParam TrasaFormError Source # | |
Defined in Trasa.Form |
bodyFormData :: BodyCodec (FormData a) Source #
this is a BodyCodec
, the intended use is to get the request body
without using wai
black magic to pass to POST
forms
liftParser :: (Text -> Either Text a) -> QueryParam -> Either TrasaFormError a Source #
lift a function which parses Text
into a function which parses a QueryParam
liftToForm :: Monad m => TrasaT m a -> TrasaFormT m a Source #
lift a TrasaT to a TrasaFormT
:: (MonadIO m, Monoid view) | |
=> ([(Text, Text)] -> view -> view) | wrap raw form html inside a form tag |
-> Text | form name prefix |
-> Form (TrasaFormT m) QueryParam err view a | the formlet |
-> TrasaT m (Result err a, view) |
run a Form
with the GET
method
:: (MonadIO m, Monoid view) | |
=> ([(Text, Text)] -> view -> view) | wrap raw form html inside a form tag |
-> Text | form name prefix |
-> Maybe (FormData a) | |
-> Form (TrasaFormT m) QueryParam err view a | the formlet |
-> TrasaT m (Result err a, view) |
run a Form
with the POST
method
trasaFormView :: Monad m => Text -> Form (TrasaFormT m) QueryParam err view a -> TrasaT m view Source #
viewForm
helper function
textError :: Text -> TrasaFormError Source #
convert Text
to a TrasaFormError
Orphan instances
Show QueryParam Source # | |
showsPrec :: Int -> QueryParam -> ShowS # show :: QueryParam -> String # showList :: [QueryParam] -> ShowS # | |
FormInput QueryParam Source # | |
type FileType QueryParam :: Type # getInputString :: FormError QueryParam err => QueryParam -> Either err String # getInputStrings :: QueryParam -> [String] # getInputText :: FormError QueryParam err => QueryParam -> Either err Text # getInputTexts :: QueryParam -> [Text] # getInputFile :: FormError QueryParam err => QueryParam -> Either err (FileType QueryParam) # | |
MonadIO m => Environment (TrasaT m) QueryParam Source # | |
environment :: FormId -> TrasaT m (Value QueryParam) # |