frame-0.1: A simple web framework.

Frame.State

Contents

Description

The state contains mutable environmental variables such as posted form fields, field validators and the session

Synopsis

Documentation

data Vars Source

The state record

Constructors

Vars 

Fields

fields :: Fields

Posted fields

validators :: Validators

Field validation functions

post :: Bool

Has a form been posted?

session :: Fields

Session fields

ajax :: Bool

Is this an AJAX request?

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

getsSource

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

startState :: VarsSource

A default empty start state

getFieldSource

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

putFieldsSource

Arguments

:: FrameState m 
=> Fields

Fields to replace with

-> m ()

Nothing (but the modified state) is returned

Replaces the fields in the state

mergeFieldsSource

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)

putFieldSource

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

delFieldSource

Arguments

:: FrameState m 
=> FieldName

FieldName to be deleted

-> m () 

Deletes a specific field in the state by the given field name

Validators

getValidatorSource

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

putValidatorsSource

Arguments

:: FrameState m 
=> Validators

Validators to replace with

-> m ()

Nothing (but the modified state) is returned

Replaces the Validators in the state

putValidatorSource

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