This module provides an implementation of non-deterministic state monad where the non-determinism distributes over state.
Author: Björn Peemöller
Version: September 2015
bindResult
:: Result a -> (a -> Result b) -> Result b
Monadic bind operation. |
runState
:: (a -> Result (b,a)) -> a -> Result (b,a)
Run a monadic computation. |
(>+=)
:: (a -> Result (b,a)) -> (b -> a -> Result (c,a)) -> a -> Result (c,a)
Monadic bind for state monad. |
(>+)
:: (a -> Result (b,a)) -> (a -> Result (c,a)) -> a -> Result (c,a)
Monadic sequence for state monad. |
(>!)
:: (a -> Result ((),a)) -> (a -> Result (b,a)) -> a -> Result (b,a)
Strict monadic sequence for state monad. |
returnS
:: a -> b -> Result (a,b)
Monadic return for state monad. |
choiceS
:: (a -> Result (b,a)) -> (a -> Result (b,a)) -> a -> Result (b,a)
Non-Deterministic choice for state monad. |
getS
:: a -> Result (a,a)
Retrieve the state from the state monad. |
getsS
:: (a -> b) -> a -> Result (b,a)
Retrieve the state from the state monad using an accessor function. |
putS
:: a -> a -> Result ((),a)
Set the state from the state monad. |
modifyS
:: (a -> a) -> a -> Result ((),a)
Modify the state from the state monad using a function. |
sequenceS
:: [a -> Result (b,a)] -> a -> Result ([b],a)
Sequence a list of monadic computations and collect the results. |
sequenceS_
:: [a -> Result (b,a)] -> a -> Result ((),a)
Sequence a list of monadic computations and discard the results. |
mapS
:: (a -> b -> Result (c,b)) -> [a] -> b -> Result ([c],b)
Perform a monadic computations for each element in a list and collect the results. |
mapS_
:: (a -> b -> Result (c,b)) -> [a] -> b -> Result ((),b)
Perform a monadic computations for each element in a list and discard the results. |
(<$>)
:: (a -> b) -> (c -> Result (a,c)) -> c -> Result (b,c)
Apply a pure function to the result of a monadic action. |
(<*>)
:: (a -> Result (b -> c,a)) -> (a -> Result (b,a)) -> a -> Result (c,a)
Apply a function originating from the first monadic computation to the result of the second monadic action. |
(<|>)
:: (a -> Result (b,a)) -> (a -> Result (b,a)) -> a -> Result (b,a)
Infix version of non-deterministic choice. |
anyS
:: (a -> b -> Result (Bool,b)) -> [a] -> b -> Result (Bool,b)
Monadic version of any .
|
allS
:: (a -> b -> Result (Bool,b)) -> [a] -> b -> Result (Bool,b)
Monadic version of all .
|
Non-Deterministic result
Constructors:
Return
:: a -> Result a
: single result
Choice
:: (Result a) -> (Result a) -> Result a
: non-deterministic choice
Non-Deterministic state monad.
Type synonym: State a b = a -> Result (b,a)
Monadic bind operation. |
Monadic bind for state monad.
|
Monadic sequence for state monad.
|
Strict monadic sequence for state monad.
|
Monadic return for state monad.
|
Non-Deterministic choice for state monad. |
Retrieve the state from the state monad using an accessor function. |
Set the state from the state monad.
|
Sequence a list of monadic computations and collect the results. |
Sequence a list of monadic computations and discard the results. |
Perform a monadic computations for each element in a list and collect the results. |
Perform a monadic computations for each element in a list and discard the results. |
Apply a pure function to the result of a monadic action.
|
Apply a function originating from the first monadic computation to the result of the second monadic action.
|