Frame.State
Contents
Description
The state contains mutable environmental variables such as posted form fields, field validators and the session
- data Vars = Vars {
- fields :: Fields
- validators :: Validators
- post :: Bool
- session :: Fields
- ajax :: Bool
- class (MonadStateGet Vars m, MonadStatePut Vars m) => FrameState m
- class MonadStateGet Vars m => FrameReader m
- get :: MonadStateGet s m => m s
- put :: MonadStatePut s m => s -> m ()
- gets :: MonadStateGet s m => (s -> a) -> m a
- startState :: Vars
- setPost :: FrameState m => Bool -> m ()
- getField :: FrameReader m => FieldName -> m (Maybe WrapperType)
- putFields :: FrameState m => Fields -> m ()
- mergeFields :: FrameState m => Maybe Fields -> m ()
- putField :: (FrameState m, FrameConfig m, Wrappable a) => FieldName -> a -> m ()
- delField :: FrameState m => FieldName -> m ()
- getValidator :: FrameReader m => FieldName -> m (Maybe [WrapperType -> Maybe String])
- putValidators :: FrameState m => Validators -> m ()
- putValidator :: FrameState m => FieldName -> [WrapperType -> Maybe String] -> m ()
Documentation
The state record
class (MonadStateGet Vars m, MonadStatePut Vars m) => FrameState m Source
Instances
(MonadStateGet Vars m, MonadStatePut Vars m) => FrameState m |
class MonadStateGet Vars m => FrameReader m Source
Instances
MonadStateGet Vars m => FrameReader m |
get :: MonadStateGet s m => m sSource
Provides get access to the state, mirroring Control.Monad.State.get
put :: MonadStatePut s m => s -> m ()Source
Provides get access to the state, mirroring Control.Monad.State.put
Arguments
:: MonadStateGet s m | |
=> (s -> a) | State projection function |
-> m a | Projected component |
Gets a specific component from the state, using the supplied projection function
A default empty start state
setPost :: FrameState m => Bool -> m ()Source
Arguments
:: FrameReader m | |
=> FieldName | FieldName to be looked up |
-> m (Maybe WrapperType) | The field (if found) |
Looks up a specific field in the state by the given field name
Arguments
:: FrameState m | |
=> Fields | Fields to replace with |
-> m () | Nothing (but the modified state) is returned |
Replaces the fields in the state
Arguments
:: FrameState m | |
=> Maybe Fields | Fields to merge |
-> m () | Nothing (but the modified state) is returned |
Merges the given fields with the existing state (existing state fields are favoured)
Arguments
:: (FrameState m, FrameConfig m, Wrappable a) | |
=> FieldName | The FieldName of the field being updated |
-> a | The (wrappable) field to update state with |
-> m () | Nothing (but the modified state) is returned |
Associate a value with a FieldName in the state
Arguments
:: FrameState m | |
=> FieldName | FieldName to be deleted |
-> m () |
Deletes a specific field in the state by the given field name
Validators
Arguments
:: FrameReader m | |
=> FieldName | Validators to look up |
-> m (Maybe [WrapperType -> Maybe String]) | The validator functions (if found) |
Look up validators functions for a particular field
Arguments
:: FrameState m | |
=> Validators | Validators to replace with |
-> m () | Nothing (but the modified state) is returned |
Replaces the Validators in the state
Arguments
:: FrameState m | |
=> FieldName | The FieldName of the validator being updated |
-> [WrapperType -> Maybe String] | The validator functions to update state with |
-> m () | Nothing (but the modified state) is returned |
Associate a set of validator functions with a FieldName in the state