hxt-9.3.1.18: A collection of tools for processing XML with Haskell.

CopyrightCopyright (C) 2005 Uwe Schmidt
LicenseMIT
MaintainerUwe Schmidt (uwe\@fh-wedel.de)
Stabilityexperimental
Portabilitymulti parameter classes and functional depenedencies required
Safe HaskellSafe
LanguageHaskell98

Control.Arrow.ArrowState

Description

Arrows for managing an explicit state

State arrows work similar to state monads. A state value is threaded through the application of arrows.

Synopsis

Documentation

class Arrow a => ArrowState s a | a -> s where Source #

The interface for accessing and changing the state component.

Multi parameter classes and functional dependencies are required.

Minimal complete definition

changeState, accessState

Methods

changeState :: (s -> b -> s) -> a b b Source #

change the state of a state arrow by applying a function for computing a new state from the old and the arrow input. Result is the arrow input

accessState :: (s -> b -> c) -> a b c Source #

access the state with a function using the arrow input as data for selecting state components.

getState :: a b s Source #

read the complete state, ignore arrow input

definition: getState = accessState (\ s x -> s)

setState :: a s s Source #

overwrite the old state

definition: setState = changeState (\ s x -> x)

nextState :: (s -> s) -> a b s Source #

change state (and ignore input) and return new state

convenience function, usefull for generating e.g. unique identifiers:

example with SLA state list arrows

newId :: SLA Int b String
newId = nextState (+1)
        >>>
        arr (('#':) . show)

runSLA 0 (newId <+> newId <+> newId) undefined
  = ["#1", "#2", "#3"]
Instances
ArrowState s (SLA s) Source # 
Instance details

Defined in Control.Arrow.StateListArrow

Methods

changeState :: (s -> b -> s) -> SLA s b b Source #

accessState :: (s -> b -> c) -> SLA s b c Source #

getState :: SLA s b s Source #

setState :: SLA s s s Source #

nextState :: (s -> s) -> SLA s b s Source #

ArrowState s (IOSLA s) Source # 
Instance details

Defined in Control.Arrow.IOStateListArrow

Methods

changeState :: (s -> b -> s) -> IOSLA s b b Source #

accessState :: (s -> b -> c) -> IOSLA s b c Source #

getState :: IOSLA s b s Source #

setState :: IOSLA s s s Source #

nextState :: (s -> s) -> IOSLA s b s Source #