FSharpx.Extras


State

Namespace: FSharpx

Nested types and modules

TypeDescription
State<'T, 'State>
StateBuilder

The state monad. The algorithm is adjusted from my original work off of Brian Beckman's http://channel9.msdn.com/shows/Going+Deep/Brian-Beckman-The-Zen-of-Expressing-State-The-State-Monad/. The approach was adjusted from Matthew Podwysocki's http://codebetter.com/blogs/matthew.podwysocki/archive/2009/12/30/much-ado-about-monads-state-edition.aspx and mirrors his final result.

Functions and values

Function or valueDescription
( *> ) x y
Signature: x:State<'?8542,'?8543> -> y:State<'?8544,'?8543> -> State<'?8544,'?8543>
Type parameters: '?8542, '?8543, '?8544

Sequence actions, discarding the value of the first argument.

CompiledName: op_MultiplyGreater

( <!> ) f m
Signature: f:('?8533 -> '?8534) -> m:State<'?8533,'?8535> -> State<'?8534,'?8535>
Type parameters: '?8533, '?8534, '?8535

Infix map

CompiledName: op_LessBangGreater

( <* ) x y
Signature: x:State<'?8546,'?8547> -> y:State<'?8548,'?8547> -> State<'?8546,'?8547>
Type parameters: '?8546, '?8547, '?8548

Sequence actions, discarding the value of the second argument.

CompiledName: op_LessMultiply

( <*> ) f m
Signature: f:State<('?8521 -> '?8522),'?8523> -> m:State<'?8521,'?8523> -> State<'?8522,'?8523>
Type parameters: '?8521, '?8522, '?8523

Sequential application

CompiledName: op_LessMultiplyGreater

( <=< ) x
Signature: x:('?8559 -> State<'?8560,'?8561>) -> ('?8562 -> State<'?8559,'?8561>) -> '?8562 -> State<'?8560,'?8561>
Type parameters: '?8559, '?8560, '?8561, '?8562

Right-to-left Kleisli composition

CompiledName: op_LessEqualsLess

( =<< ) f m
Signature: f:('?8517 -> State<'?8518,'?8519>) -> m:State<'?8517,'?8519> -> State<'?8518,'?8519>
Type parameters: '?8517, '?8518, '?8519

Flipped >>=

CompiledName: op_EqualsLessLess

( >=> ) f g x
Signature: f:('?8554 -> State<'?8555,'?8556>) -> g:('?8555 -> State<'?8557,'?8556>) -> x:'?8554 -> State<'?8557,'?8556>
Type parameters: '?8554, '?8555, '?8556, '?8557

Left-to-right Kleisli composition

CompiledName: op_GreaterEqualsGreater

( >>. ) m f
Signature: m:State<'?8550,'?8551> -> f:State<'?8552,'?8551> -> State<'?8552,'?8551>
Type parameters: '?8550, '?8551, '?8552

Sequentially compose two state actions, discarding any value produced by the first

CompiledName: op_GreaterGreaterDot

( >>= ) m f
Signature: m:State<'?8513,'?8514> -> f:('?8513 -> State<'?8515,'?8514>) -> State<'?8515,'?8514>
Type parameters: '?8513, '?8514, '?8515

Sequentially compose two actions, passing any value produced by the first as an argument to the second.

CompiledName: op_GreaterGreaterEquals

ap m f
Signature: m:State<'?8525,'?8526> -> f:State<('?8525 -> '?8527),'?8526> -> State<'?8527,'?8526>
Type parameters: '?8525, '?8526, '?8527

Sequential application

bind k m s
Signature: k:('?8470 -> '?8471 -> '?8472) -> m:('?8473 -> '?8470 * '?8471) -> s:'?8473 -> '?8472
Type parameters: '?8470, '?8471, '?8472, '?8473
empty s
Signature: s:'?8468 -> unit * '?8468
Type parameters: '?8468
eval m s
Signature: m:('?8460 -> '?8461 * '?8462) -> s:'?8460 -> '?8461
Type parameters: '?8460, '?8461, '?8462
exec m s
Signature: m:('?8464 -> '?8465 * '?8466) -> s:'?8464 -> '?8466
Type parameters: '?8464, '?8465, '?8466
foldM f s
Signature: f:('?8564 -> '?8565 -> State<'?8564,'?8566>) -> s:'?8564 -> seq<'?8565> -> State<'?8564,'?8566>
Type parameters: '?8564, '?8565, '?8566
getState s
Signature: s:'c -> 'c * 'c
Type parameters: 'c
lift2 f a b
Signature: f:('?8537 -> '?8538 -> '?8539) -> a:State<'?8537,'?8540> -> b:State<'?8538,'?8540> -> State<'?8539,'?8540>
Type parameters: '?8537, '?8538, '?8539, '?8540

Promote a function to a monad/applicative, scanning the monadic/applicative arguments from left to right.

map f m
Signature: f:('?8529 -> '?8530) -> m:State<'?8529,'?8531> -> State<'?8530,'?8531>
Type parameters: '?8529, '?8530, '?8531

Transforms a State value by using a specified mapping function.

mapM f x
Signature: f:('?8571 -> State<'?8572,'?8573>) -> x:'?8571 list -> State<'?8572 list,'?8573>
Type parameters: '?8571, '?8572, '?8573
putState s arg2
Signature: s:'?8457 -> '?8458 -> unit * '?8457
Type parameters: '?8457, '?8458
returnM x
Signature: x:'?8510 -> State<'?8510,'?8511>
Type parameters: '?8510, '?8511

Inject a value into the State type

sequence s
Signature: s:State<'?8568,'?8569> list -> State<'?8568 list,'?8569>
Type parameters: '?8568, '?8569
state
Signature: StateBuilder
Fork me on GitHub