HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleyesod-form-1.7.9Haskell2010

Yesod.Form.Types

  • 13 types

Helpers

6 declarations
datadata Enctype
#

The encoding type required by a form. The ToHtml instance produces values that can be inserted directly into HTML.

Instances7Bounded, Enum, Eq, Semigroup, Monoid, ToMarkup, …
datadata FormResult a
#

A form can produce three different results: there was no data available, the data was invalid, or there was a successful parse.

The Applicative instance will concatenate the failure messages in two FormResults. The Alternative instance will choose FormFailure before FormSuccess, and FormMissing last of all.

Instances9Functor, Applicative, Foldable, Traversable, Alternative, Eq, …
datadata FormMessage
#
Instances3Eq, Read, Show

Form

3 declarations
typetype WForm (m :: Type -> Type) a = MForm (WriterT [FieldView (HandlerSite m)] m) a
#

MForm variant stacking a WriterT. The following code example using a monadic form MForm:

formToAForm $ do
  (field1F, field1V) <- mreq textField MsgField1 Nothing
  (field2F, field2V) <- mreq (checkWith field1F textField) MsgField2 Nothing
  (field3F, field3V) <- mreq (checkWith field1F textField) MsgField3 Nothing
  return
    ( MyForm <$> field1F <*> field2F <*> field3F
    , [field1V, field2V, field3V]
    )

Could be rewritten as follows using WForm:

wFormToAForm $ do
  field1F <- wreq textField MsgField1 Nothing
  field2F <- wreq (checkWith field1F textField) MsgField2 Nothing
  field3F <- wreq (checkWith field1F textField) MsgField3 Nothing
  return $ MyForm <$> field1F <*> field2F <*> field3F
newtypenewtype AForm (m :: Type -> Type) a
#
Instances6MonadTrans, Monad, Functor, Applicative, Semigroup, Monoid

Build forms

4 declarations