LanguageExt.Core ► Traits ► Monads ► Monad
Contents
- 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)
- 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)
- Monad <M>
- Bind <A, B> (K<M, A> ma, Func<A, K<M, B>> f)
- Flatten <A> (K<M, K<M, A>> mma)
- Map <A, B> (Func<A, B> f, K<M, A> ma)
- LiftIO <A> (IO<A> ma)
- UnliftIO <A> ()
- WithRunInIO <A, B> (Func<Func<K<M, A>, IO<A>>, IO<B>> inner)
- MonadIO
class MonadExtensions Source #
Monad module
Methods
method K<M, B> Bind <M, A, B> ( this K<M, A> ma, Func<A, K<M, B>> f) Source #
Monad bind operation
Parameters
type | A | Initial bound value type |
type | B | Intermediate bound value type |
param | f | Monadic bind function |
returns | M |
method K<M, B> Bind <M, A, B> ( this K<M, A> ma, Func<A, Pure<B>> f) Source #
Monad bind operation
Parameters
type | A | Initial bound value type |
type | B | Intermediate bound value type |
param | f | Monadic bind function |
returns | M |
method K<M, B> Bind <M, A, B> ( this K<M, A> ma, Func<A, K<IO, B>> f) Source #
Monad bind operation
Parameters
type | A | Initial bound value type |
type | B | Intermediate bound value type |
param | f | Monadic bind function |
returns | M |
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
Parameters
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 |
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
Parameters
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 |
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
Parameters
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 |
class MonadExtensions Source #
Monad module
Methods
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.
Parameters
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 |
Examples
var mx = Seq<Option
var ma = mx.KindT<Seq, Option, Option
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.
Parameters
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 |
Examples
var mx = Seq<Option
var ma = mx.KindT<Seq, Option, Option
Monad module
Methods
Monad trait
Parameters
type | M | Self referring trait |
Methods
method K<M, A> LiftIO <A> (IO<A> ma) Source #
Lifts the IO monad into a monad transformer stack.
If this method isn't overloaded in the inner monad or any monad in the stack on the way to the inner monad then it will throw an exception.
This isn't ideal - however it appears to be the only way to achieve this kind of functionality in C# without resorting to magic.
Parameters
type | A | Bound value type |
param | ma | IO computation to lift |
returns | The outer monad with the IO monad lifted into it |
method K<M, Func<K<M, A>, IO<A>>> UnliftIO <A> () Source #
Unlifts the IO monad from the monad transformer stack.
If the WithRunInIO
method isn't overloaded in the inner monad or any
monad in the stack on the way to the inner monad then it will throw an
exception.
This isn't ideal - however it appears to be the only way to achieve this kind of functionality in C# without resorting to magic.
Parameters
type | A | Bound value type |
returns | The outer monad with the IO monad lifted into it |
method K<M, B> WithRunInIO <A, B> (Func<Func<K<M, A>, IO<A>>, IO<B>> inner) Source #
Unlifts the IO monad from the monad transformer stack.
If this method isn't overloaded in the inner monad or any monad in the stack on the way to the inner monad then it will throw an exception.
This isn't ideal - however it appears to be the only way to achieve this kind of functionality in C# without resorting to magic.
Parameters
type | A | Bound value type |
param | mma | IO computation to lift |
returns | The outer monad with the IO monad lifted into it |
Monad module
Methods
method K<M, A> liftIO <M, A> (IO<A> ma) Source #
Embeds the IO
monad into the M<A>
monad. NOTE: This will fail if the monad transformer
stack doesn't have an IO
monad as its inner-most monad.
method K<M, Func<K<M, A>, IO<A>>> unliftIO <M, A> () Source #
Unlifts the IO monad from the monad transformer stack.
If the WithRunInIO
method isn't overloaded in the inner monad or any
monad in the stack on the way to the inner monad then it will throw an
exception.
This isn't ideal - however it appears to be the only way to achieve this kind of functionality in C# without resorting to magic.
Parameters
type | A | Bound value type |
returns | The outer monad with the IO monad lifted into it |
method K<M, B> withRunInIO <M, A, B> (Func<Func<K<M, A>, IO<A>>, IO<B>> inner) Source #
Unlifts the IO monad from the monad transformer stack.
If the WithRunInIO
method isn't overloaded in the inner monad or any monad
in the stack on the way to the inner monad then it will throw an exception.
This isn't ideal - however it appears to be the only way to achieve this kind of functionality in C# without resorting to magic.
Parameters
type | A | Bound value type |
param | mma | IO computation to lift |
returns | The outer monad with the IO monad lifted into it |