# Module ErrorState

A combination of Error and state monad like `ErrorT State` in Haskell.

Author: Bjoern Peemoeller

Version: September 2014

## Summary of exported operations:

 ```evalES :: (a -> Either b (c,a)) -> a -> Either b c```    Evaluate an `ES` monad ```returnES :: a -> b -> Either c (a,b)```    Lift a value into the `ES` monad ```failES :: a -> b -> Either a (c,b)```    Failing computation in the `ES` monad ```(>+=) :: (a -> Either b (c,a)) -> (c -> a -> Either b (d,a)) -> a -> Either b (d,a)```    Bind of the `ES` monad ```(>+) :: (a -> Either b (c,a)) -> (a -> Either b (d,a)) -> a -> Either b (d,a)```    Sequence operator of the `ES` monad ```(<\$>) :: (a -> b) -> (c -> Either d (a,c)) -> c -> Either d (b,c)```    Apply a pure function onto a monadic value. ```(<*>) :: (a -> Either b (c -> d,a)) -> (a -> Either b (c,a)) -> a -> Either b (d,a)```    Apply a function yielded by a monadic action to a monadic value. ```gets :: a -> Either b (a,a)```    Retrieve the current state ```puts :: a -> a -> Either b ((),a)```    Replace the current state ```modify :: (a -> a) -> a -> Either b ((),a)```    Modify the current state ```mapES :: (a -> b -> Either c (d,b)) -> [a] -> b -> Either c ([d],b)```    Map a monadic function on all elements of a list by sequencing the effects. ```concatMapES :: (a -> b -> Either c ([d],b)) -> [a] -> b -> Either c ([d],b)```    Same as `concatMap`, but for a monadic function. ```mapAccumES :: (a -> b -> c -> Either d ((a,e),c)) -> a -> [b] -> c -> Either d ((a,[e]),c)```    Same as `mapES` but with an additional accumulator threaded through.

## Exported datatypes:

ES

Type synonym: `ES a b c = b -> Either a (c,b)`

## Exported operations:

 ```evalES :: (a -> Either b (c,a)) -> a -> Either b c```    Evaluate an `ES` monad
 ```returnES :: a -> b -> Either c (a,b)```    Lift a value into the `ES` monad Further infos: solution complete, i.e., able to compute all solutions
 ```failES :: a -> b -> Either a (c,b)```    Failing computation in the `ES` monad Further infos: solution complete, i.e., able to compute all solutions
 ```(>+=) :: (a -> Either b (c,a)) -> (c -> a -> Either b (d,a)) -> a -> Either b (d,a)```    Bind of the `ES` monad Further infos: defined as left-associative infix operator with precedence 1
 ```(>+) :: (a -> Either b (c,a)) -> (a -> Either b (d,a)) -> a -> Either b (d,a)```    Sequence operator of the `ES` monad Further infos: defined as left-associative infix operator with precedence 1
 ```(<\$>) :: (a -> b) -> (c -> Either d (a,c)) -> c -> Either d (b,c)```    Apply a pure function onto a monadic value. Further infos: defined as left-associative infix operator with precedence 4
 ```(<*>) :: (a -> Either b (c -> d,a)) -> (a -> Either b (c,a)) -> a -> Either b (d,a)```    Apply a function yielded by a monadic action to a monadic value. Further infos: defined as left-associative infix operator with precedence 4
 ```gets :: a -> Either b (a,a)```    Retrieve the current state Further infos: solution complete, i.e., able to compute all solutions
 ```puts :: a -> a -> Either b ((),a)```    Replace the current state Further infos: solution complete, i.e., able to compute all solutions
 ```modify :: (a -> a) -> a -> Either b ((),a)```    Modify the current state
 ```mapES :: (a -> b -> Either c (d,b)) -> [a] -> b -> Either c ([d],b)```    Map a monadic function on all elements of a list by sequencing the effects.
 ```concatMapES :: (a -> b -> Either c ([d],b)) -> [a] -> b -> Either c ([d],b)```    Same as `concatMap`, but for a monadic function.
 ```mapAccumES :: (a -> b -> c -> Either d ((a,e),c)) -> a -> [b] -> c -> Either d ((a,[e]),c)```    Same as `mapES` but with an additional accumulator threaded through.