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

Safe HaskellNone
LanguageHaskell98

Yesod.Form.Types

Contents

Synopsis

Helpers

data Enctype Source #

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

Constructors

UrlEncoded 
Multipart 

data FormResult a Source #

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.

Instances
Functor FormResult Source # 
Instance details

Defined in Yesod.Form.Types

Methods

fmap :: (a -> b) -> FormResult a -> FormResult b #

(<$) :: a -> FormResult b -> FormResult a #

Applicative FormResult Source # 
Instance details

Defined in Yesod.Form.Types

Methods

pure :: a -> FormResult a #

(<*>) :: FormResult (a -> b) -> FormResult a -> FormResult b #

liftA2 :: (a -> b -> c) -> FormResult a -> FormResult b -> FormResult c #

(*>) :: FormResult a -> FormResult b -> FormResult b #

(<*) :: FormResult a -> FormResult b -> FormResult a #

Foldable FormResult Source #

Since: 1.4.5

Instance details

Defined in Yesod.Form.Types

Methods

fold :: Monoid m => FormResult m -> m #

foldMap :: Monoid m => (a -> m) -> FormResult a -> m #

foldr :: (a -> b -> b) -> b -> FormResult a -> b #

foldr' :: (a -> b -> b) -> b -> FormResult a -> b #

foldl :: (b -> a -> b) -> b -> FormResult a -> b #

foldl' :: (b -> a -> b) -> b -> FormResult a -> b #

foldr1 :: (a -> a -> a) -> FormResult a -> a #

foldl1 :: (a -> a -> a) -> FormResult a -> a #

toList :: FormResult a -> [a] #

null :: FormResult a -> Bool #

length :: FormResult a -> Int #

elem :: Eq a => a -> FormResult a -> Bool #

maximum :: Ord a => FormResult a -> a #

minimum :: Ord a => FormResult a -> a #

sum :: Num a => FormResult a -> a #

product :: Num a => FormResult a -> a #

Traversable FormResult Source #

Since: 1.4.5

Instance details

Defined in Yesod.Form.Types

Methods

traverse :: Applicative f => (a -> f b) -> FormResult a -> f (FormResult b) #

sequenceA :: Applicative f => FormResult (f a) -> f (FormResult a) #

mapM :: Monad m => (a -> m b) -> FormResult a -> m (FormResult b) #

sequence :: Monad m => FormResult (m a) -> m (FormResult a) #

Alternative FormResult Source #

Since: 1.4.15

Instance details

Defined in Yesod.Form.Types

Eq a => Eq (FormResult a) Source # 
Instance details

Defined in Yesod.Form.Types

Methods

(==) :: FormResult a -> FormResult a -> Bool #

(/=) :: FormResult a -> FormResult a -> Bool #

Show a => Show (FormResult a) Source # 
Instance details

Defined in Yesod.Form.Types

Semigroup m => Semigroup (FormResult m) Source # 
Instance details

Defined in Yesod.Form.Types

Monoid m => Monoid (FormResult m) Source # 
Instance details

Defined in Yesod.Form.Types

type Env = Map Text [Text] Source #

data Ints Source #

Constructors

IntCons Int Ints 
IntSingle Int 
Instances
Show Ints Source # 
Instance details

Defined in Yesod.Form.Types

Methods

showsPrec :: Int -> Ints -> ShowS #

show :: Ints -> String #

showList :: [Ints] -> ShowS #

Form

type WForm m a = MForm (WriterT [FieldView (HandlerSite m)] m) a Source #

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

Since: 1.4.14

newtype AForm m a Source #

Constructors

AForm 
Instances
MonadTrans AForm Source # 
Instance details

Defined in Yesod.Form.Types

Methods

lift :: Monad m => m a -> AForm m a #

Monad m => Functor (AForm m) Source # 
Instance details

Defined in Yesod.Form.Types

Methods

fmap :: (a -> b) -> AForm m a -> AForm m b #

(<$) :: a -> AForm m b -> AForm m a #

Monad m => Applicative (AForm m) Source # 
Instance details

Defined in Yesod.Form.Types

Methods

pure :: a -> AForm m a #

(<*>) :: AForm m (a -> b) -> AForm m a -> AForm m b #

liftA2 :: (a -> b -> c) -> AForm m a -> AForm m b -> AForm m c #

(*>) :: AForm m a -> AForm m b -> AForm m b #

(<*) :: AForm m a -> AForm m b -> AForm m a #

(Monad m, Semigroup a) => Semigroup (AForm m a) Source # 
Instance details

Defined in Yesod.Form.Types

Methods

(<>) :: AForm m a -> AForm m a -> AForm m a #

sconcat :: NonEmpty (AForm m a) -> AForm m a #

stimes :: Integral b => b -> AForm m a -> AForm m a #

(Monad m, Monoid a) => Monoid (AForm m a) Source # 
Instance details

Defined in Yesod.Form.Types

Methods

mempty :: AForm m a #

mappend :: AForm m a -> AForm m a -> AForm m a #

mconcat :: [AForm m a] -> AForm m a #

Build forms

data Field m a Source #

Constructors

Field 

data FieldSettings master Source #

Constructors

FieldSettings 

Fields

Instances
IsString (FieldSettings a) Source # 
Instance details

Defined in Yesod.Form.Types

data FieldView site Source #

Constructors

FieldView 

type FieldViewFunc m a Source #

Arguments

 = Text

ID

-> Text

Name

-> [(Text, Text)]

Attributes

-> Either Text a

Either (invalid text) or (legitimate result)

-> Bool

Required?

-> WidgetFor (HandlerSite m) ()