- MonadExtensions
- Bind <M, A, B> ( this K<M, A> ma, Func<A, K<M, B>> f)
- Bind <M, A, B> ( this K<M, A> ma, Func<A, Pure<B>> f)
- Bind <M, A, B> ( this K<M, A> ma, Func<A, K<IO, B>> f)
- SelectMany <M, A, B, C> ( this K<M, A> ma, Func<A, K<M, B>> bind, Func<A, B, C> project)
- SelectMany <M, A, B, C> ( this K<M, A> ma, Func<A, Pure<B>> bind, Func<A, B, C> project)
- SelectMany <M, A, B, C> ( this K<M, A> ma, Func<A, K<IO, B>> bind, Func<A, B, C> project)
- Flatten <M, A> (this K<M, K<M, A>> mma)
- MonadExtensions
- BindT <M, N, A, B> (this K<M, K<N, A>> mna, Func<A, K<N, B>> f)
- BindT <M, N, A, B> (this K<M, K<N, A>> mna, Func<A, K<M, K<N, B>>> f)
- MonadLaw <F>
- assert (Func<K<F, int>, K<F, int>, bool>? equals = null)
- validate (Func<K<F, int>, K<F, int>, bool>? equals = null)
- leftIdentityLaw (Func<K<F, int>, K<F, int>, bool> equals)
- rightIdentityLaw (Func<K<F, int>, K<F, int>, bool> equals)
- associativityLaw (Func<K<F, int>, K<F, int>, bool> equals)
- Monad
- pure <M, A> (A value)
- flatten <M, A> (K<M, K<M, A>> mma)
- bind <M, A, B> (K<M, A> ma, Func<A, K<M, B>> f)
- bind <M, MB, A, B> (K<M, A> ma, Func<A, MB> f)
- when <M> (K<M, bool> Pred, K<M, Unit> Then)
- when <M> (K<M, bool> Pred, K<IO, Unit> Then)
- when <M> (K<M, bool> Pred, Pure<Unit> Then)
- unless <M> (K<M, bool> Pred, K<M, Unit> Then)
- unless <M> (K<M, bool> Pred, K<IO, Unit> Then)
- unless <M> (K<M, bool> Pred, Pure<Unit> Then)
- iff <M, A> (K<M, bool> Pred, K<M, A> Then, K<M, A> Else)
- iff <M, A> (K<M, bool> Pred, K<M, A> Then, K<IO, A> Else)
- iff <M, A> (K<M, bool> Pred, K<IO, A> Then, K<M, A> Else)
- iff <M, A> (K<M, bool> Pred, K<IO, A> Then, K<IO, A> Else)
- iff <M, A> (K<M, bool> Pred, K<M, A> Then, Pure<A> Else)
- iff <M, A> (K<M, bool> Pred, Pure<A> Then, K<M, A> Else)
- iff <M, A> (K<M, bool> Pred, Pure<A> Then, Pure<A> Else)
- iff <M, A> (K<M, bool> Pred, Pure<A> Then, K<IO, A> Else)
- iff <M, A> (K<M, bool> Pred, K<IO, A> Then, Pure<A> Else)
- Monad <M>
class MonadExtensions Source #
Monad module
method K<M, B> Bind <M, A, B> ( this K<M, A> ma, Func<A, K<M, B>> f) Source #
Monad bind operation
type | A | Initial bound value type |
type | B | Intermediate bound value type |
param | f | Monadic bind function |
returns | M〈B〉 |
method K<M, B> Bind <M, A, B> ( this K<M, A> ma, Func<A, Pure<B>> f) Source #
Monad bind operation
type | A | Initial bound value type |
type | B | Intermediate bound value type |
param | f | Monadic bind function |
returns | M〈B〉 |
method K<M, B> Bind <M, A, B> ( this K<M, A> ma, Func<A, K<IO, B>> f) Source #
Monad bind operation
type | A | Initial bound value type |
type | B | Intermediate bound value type |
param | f | Monadic bind function |
returns | M〈B〉 |
method K<M, C> SelectMany <M, A, B, C> ( this K<M, A> ma, Func<A, K<M, B>> bind, Func<A, B, C> project) Source #
Monad bind operation
type | A | Initial bound value type |
type | B | Intermediate bound value type |
type | C | Target bound value type |
param | bind | Monadic bind function |
param | project | Projection function |
returns | M〈C〉 |
method K<M, C> SelectMany <M, A, B, C> ( this K<M, A> ma, Func<A, Pure<B>> bind, Func<A, B, C> project) Source #
Monad bind operation
type | A | Initial bound value type |
type | B | Intermediate bound value type |
type | C | Target bound value type |
param | bind | Monadic bind function |
param | project | Projection function |
returns | M〈C〉 |
method K<M, C> SelectMany <M, A, B, C> ( this K<M, A> ma, Func<A, K<IO, B>> bind, Func<A, B, C> project) Source #
Monad bind operation
type | A | Initial bound value type |
type | B | Intermediate bound value type |
type | C | Target bound value type |
param | bind | Monadic bind function |
param | project | Projection function |
returns | M〈C〉 |
class MonadExtensions Source #
Monad module
method K<M, K<N, B>> BindT <M, N, A, B> (this K<M, K<N, A>> mna, Func<A, K<N, B>> f) Source #
Runs a monadic bind operation on the nested monads
If you're working with an inner monad that is concrete then you will first need to
call KindT
to cast the monad to a more general K
version. This enables the
T
variant extensions (like BindT
, `MapT, etc.) to work without providing
excessive generic arguments all the way down the chain.
type | M | Outer monad trait |
type | N | Inner monad trait |
type | A | Input bound value |
type | B | Output bound value |
param | mna | Nested monadic value |
param | f | Bind function |
returns | Mapped value |
var mx = Seq〈Option〈int〉〉(Some(1), Some(2), Some(3));
var ma = mx.MapT(a => a + 1);
method K<M, K<N, B>> BindT <M, N, A, B> (this K<M, K<N, A>> mna, Func<A, K<M, K<N, B>>> f) Source #
Runs a monadic bind operation on the nested monads
If you're working with an inner monad that is concrete then you will first need to
call KindT
to cast the monad to a more general K
version. This enables the
T
variant extensions (like BindT
, `MapT, etc.) to work without providing
excessive generic arguments all the way down the chain.
type | M | Outer monad trait |
type | N | Inner monad trait |
type | A | Input bound value |
type | B | Output bound value |
param | mna | Nested monadic value |
param | f | Bind function |
returns | Mapped value |
var mx = Seq〈Option〈int〉〉(Some(1), Some(2), Some(3));
var ma = mx.BindT(a => Seq(Some(a + 1))) .MapT(a => a + 1);;
Functions that test that monad laws hold for the F
monad provided.
NOTE: Equals
must be implemented for the K〈F, *〉
derived-type, so that the laws
can be proven to be true. If your monad doesn't have Equals
then you must provide
the optional equals
parameter so that the equality of outcomes can be tested.
type | F | Functor type |
method Unit assert (Func<K<F, int>, K<F, int>, bool>? equals = null) Source #
Assert that the monad laws hold
NOTE: Equals
must be implemented for the K〈F, *〉
derived-type, so that the laws
can be proven to be true. If your monad doesn't have Equals
then you must provide
the optional equals
parameter so that the equality of outcomes can be tested.
method Validation<Error, Unit> validate (Func<K<F, int>, K<F, int>, bool>? equals = null) Source #
Validate that the monad laws hold
NOTE: Equals
must be implemented for the K〈F, *〉
derived-type, so that the laws
can be proven to be true. If your monad doesn't have Equals
then you must provide
the optional equals
parameter so that the equality of outcomes can be tested.
method Validation<Error, Unit> leftIdentityLaw (Func<K<F, int>, K<F, int>, bool> equals) Source #
Validate the left-identity law
NOTE: Equals
must be implemented for the K〈F, *〉
derived-type, so that the laws
can be proven to be true. If your monad doesn't have Equals
then you must provide
the optional equals
parameter so that the equality of outcomes can be tested.
method Validation<Error, Unit> rightIdentityLaw (Func<K<F, int>, K<F, int>, bool> equals) Source #
Validate the right-identity law
NOTE: Equals
must be implemented for the K〈F, *〉
derived-type, so that the laws
can be proven to be true. If your monad doesn't have Equals
then you must provide
the optional equals
parameter so that the equality of outcomes can be tested.
method Validation<Error, Unit> associativityLaw (Func<K<F, int>, K<F, int>, bool> equals) Source #
Validate the associativity law
NOTE: Equals
must be implemented for the K〈F, *〉
derived-type, so that the laws
can be proven to be true. If your monad doesn't have Equals
then you must provide
the optional equals
parameter so that the equality of outcomes can be tested.
Monad module
method MB bind <M, MB, A, B> (K<M, A> ma, Func<A, MB> f) Source #
method K<M, Unit> when <M> (K<M, bool> Pred, K<M, Unit> Then) Source #
When the predicate evaluates to true
, compute Then
type | M | Monad |
param | Pred | Predicate |
param | Then | Computation |
returns | Unit monad |
method K<M, Unit> when <M> (K<M, bool> Pred, K<IO, Unit> Then) Source #
When the predicate evaluates to true
, compute Then
type | M | Monad |
param | Pred | Predicate |
param | Then | Computation |
returns | Unit monad |
method K<M, Unit> when <M> (K<M, bool> Pred, Pure<Unit> Then) Source #
When the predicate evaluates to true
, compute Then
type | M | Monad |
param | Pred | Predicate |
param | Then | Computation |
returns | Unit monad |
method K<M, Unit> unless <M> (K<M, bool> Pred, K<M, Unit> Then) Source #
When the predicate evaluates to false
, compute Then
type | M | Monad |
param | Pred | Predicate |
param | Then | Computation |
returns | Unit monad |
method K<M, Unit> unless <M> (K<M, bool> Pred, K<IO, Unit> Then) Source #
When the predicate evaluates to false
, compute Then
type | M | Monad |
param | Pred | Predicate |
param | Then | Computation |
returns | Unit monad |
method K<M, Unit> unless <M> (K<M, bool> Pred, Pure<Unit> Then) Source #
When the predicate evaluates to false
, compute Then
type | M | Monad |
param | Pred | Predicate |
param | Then | Computation |
returns | Unit monad |
method K<M, A> iff <M, A> (K<M, bool> Pred, K<M, A> Then, K<M, A> Else) Source #
Compute the predicate and depending on its state compute Then
or Else
type | M | Monad |
param | Pred | Predicate |
param | Then | Computation |
param | Else | Computation |
returns | Unit monad |
method K<M, A> iff <M, A> (K<M, bool> Pred, K<M, A> Then, K<IO, A> Else) Source #
Compute the predicate and depending on its state compute Then
or Else
type | M | Monad |
param | Pred | Predicate |
param | Then | Computation |
param | Else | Computation |
returns | Unit monad |
method K<M, A> iff <M, A> (K<M, bool> Pred, K<IO, A> Then, K<M, A> Else) Source #
Compute the predicate and depending on its state compute Then
or Else
type | M | Monad |
param | Pred | Predicate |
param | Then | Computation |
param | Else | Computation |
returns | Unit monad |
method K<M, A> iff <M, A> (K<M, bool> Pred, K<IO, A> Then, K<IO, A> Else) Source #
Compute the predicate and depending on its state compute Then
or Else
type | M | Monad |
param | Pred | Predicate |
param | Then | Computation |
param | Else | Computation |
returns | Unit monad |
method K<M, A> iff <M, A> (K<M, bool> Pred, K<M, A> Then, Pure<A> Else) Source #
Compute the predicate and depending on its state compute Then
or Else
type | M | Monad |
param | Pred | Predicate |
param | Then | Computation |
param | Else | Computation |
returns | Unit monad |
method K<M, A> iff <M, A> (K<M, bool> Pred, Pure<A> Then, K<M, A> Else) Source #
Compute the predicate and depending on its state compute Then
or Else
type | M | Monad |
param | Pred | Predicate |
param | Then | Computation |
param | Else | Computation |
returns | Unit monad |
method K<M, A> iff <M, A> (K<M, bool> Pred, Pure<A> Then, Pure<A> Else) Source #
Compute the predicate and depending on its state compute Then
or Else
type | M | Monad |
param | Pred | Predicate |
param | Then | Computation |
param | Else | Computation |
returns | Unit monad |