LanguageExt.Core

LanguageExt.Core Traits Monads MonadIO

Contents

class MonadIOExtensions Source #

Methods

method K<M, B> Bind <M, A, B> ( this K<M, A> ma, Func<A, IO<B>> f) Source #

where M : MonadIO<M>, Monad<M>

Monad bind operation

method K<M, B> Bind <M, A, B> ( this IO<A> ma, Func<A, K<M, B>> f) Source #

where M : MonadIO<M>, Monad<M>

Monad bind operation

method K<M, C> SelectMany <M, A, B, C> (this K<M, A> ma, Func<A, IO<B>> bind, Func<A, B, C> project) Source #

where M : MonadIO<M>, Monad<M>

Monad bind operation

method K<M, C> SelectMany <M, A, B, C> (this IO<A> ma, Func<A, K<M, B>> bind, Func<A, B, C> project) Source #

where M : MonadIO<M>, Monad<M>

Monad bind operation

method K<M, ForkIO<A>> ForkIO <M, A> (this K<M, A> ma, Option<TimeSpan> timeout = default) Source #

where M : MonadUnliftIO<M>

Queue this IO operation to run on the thread-pool.

Parameters

param timeout

Maximum time that the forked IO operation can run for. None for no timeout.

returns

Returns a ForkIO data-structure that contains two IO effects that can be used to either cancel the forked IO operation or to await the result of it.

method K<M, ForkIO<A>> ForkIOMaybe <M, A> (this K<M, A> ma, Option<TimeSpan> timeout = default) Source #

where M : MonadIO<M>

Queue this IO operation to run on the thread-pool.

Parameters

param timeout

Maximum time that the forked IO operation can run for. None for no timeout.

returns

Returns a ForkIO data-structure that contains two IO effects that can be used to either cancel the forked IO operation or to await the result of it.

class MonadIO Source #

Monad module

Methods

method K<M, Unit> when <M> (K<M, bool> Pred, K<IO, Unit> Then) Source #

where M : MonadIO<M>

When the predicate evaluates to true, compute Then

Parameters

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 #

where M : MonadIO<M>

When the predicate evaluates to false, compute Then

Parameters

type M

Monad

param Pred

Predicate

param Then

Computation

returns

Unit monad

method K<M, A> liftIO <M, A> (IO<A> ma) Source #

where M : Maybe.MonadIO<M>, Monad<M>

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 innermost monad.

method K<M, A> liftIO <M, A> (K<IO, A> ma) Source #

where M : Maybe.MonadIO<M>, Monad<M>

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 innermost monad.

method K<M, EnvIO> envIO <M> () Source #

where M : MonadIO<M>, Monad<M>

Get the environment value threaded through the IO computation

Parameters

type M

Trait

returns

Lifted environment value

method K<M, CancellationToken> token <M> () Source #

where M : MonadIO<M>, Monad<M>

Get the cancellation token threaded through the IO computation

Parameters

type M

Trait

returns

Lifted cancellation token

method K<M, CancellationTokenSource> tokenSource <M> () Source #

where M : MonadIO<M>, Monad<M>

Get the cancellation token-source threaded through the IO computation

Parameters

type M

Trait

returns

Lifted cancellation token-source

method K<M, Option<SynchronizationContext>> syncContext <M> () Source #

where M : MonadIO<M>, Monad<M>

Get the synchronisation-context threaded through the IO computation

Parameters

type M

Trait

returns

Lifted synchronisation-context

interface MonadIO <M> Source #

where M : MonadIO<M>

Monad that is either the IO monad or a transformer with the IO monad in its stack

Parameters

type M

Self-referring trait

Properties

property K<M, EnvIO> EnvIO Source #

property K<M, CancellationToken> Token Source #

property K<M, CancellationTokenSource> TokenSource Source #

property K<M, Option<SynchronizationContext>> SyncContext Source #

Methods

method K<M, A> LiftIO <A> (K<IO, A> ma) Source #

Lifts the IO monad into a monad transformer stack.

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, A> LiftIO <A> (IO<A> ma) Source #

Lifts the IO monad into a monad transformer stack.

IMPLEMENTATION REQUIRED: If this method isn't overloaded in this monad or any monad in the stack on the way to the inner-monad, then it will throw an exception.

This isn't ideal, 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, C> SelectMany <A, B, C> (K<M, A> ma, Func<A, IO<B>> bind, Func<A, B, C> project) Source #

method K<M, C> SelectMany <A, B, C> (IO<A> ma, Func<A, K<M, B>> bind, Func<A, B, C> project) Source #