LanguageExt.Core

LanguageExt.Core Monads State and Environment Monads Reader

Contents

delegate Reader <Env, A> Source #

struct ReaderResult <A> Source #

Fields

field ReaderResult<A> Bottom = new ReaderResult<A>() Source #

Properties

property bool IsFaulted Source #

Methods

method ReaderResult<A> New (A value) Source #

method ReaderResult<A> New (Error error) Source #

method B Match <B> (Func<A, B> Succ, Func<Error, B> Fail) Source #

method Unit Match (Action<A> Succ, Action<Error> Fail) Source #

method A IfFail (A value) Source #

method A IfFailThrow () Source #

method Option<A> ToOption () Source #

method OptionUnsafe<A> ToOptionUnsafe () Source #

method OptionAsync<A> ToOptionAsync () Source #

method Seq<A> ToSeq () Source #

method Lst<A> ToList () Source #

method Either<Error, A> ToEither () Source #

method Either<L, A> ToEither <L> (Func<Error, L> Left) Source #

method EitherUnsafe<Error, A> ToEitherUnsafe () Source #

method EitherUnsafe<L, A> ToEitherUnsafe <L> (Func<Error, L> Left) Source #

method EitherAsync<Error, A> ToEitherAsync () Source #

method EitherAsync<L, A> ToEitherAsync <L> (Func<Error, L> Left) Source #

method Try<A> ToTry () Source #

method TryAsync<A> ToTryAsync () Source #

method bool Equals (object obj) Source #

method int GetHashCode () Source #

method bool Equals (ReaderResult<A> right) Source #

method bool Equals (A right) Source #

method void Deconstruct (out A Value, out Option<Error> Error) Source #

Operators

operator == (ReaderResult<A> left, A right) Source #

operator != (ReaderResult<A> left, A right) Source #

operator == (ReaderResult<A> left, ReaderResult<A> right) Source #

operator != (ReaderResult<A> left, ReaderResult<A> right) Source #

class ReaderExt Source #

Reader monad extensions

Methods

method Reader<Env, A> Flatten <Env, A> (this Reader<Env, Reader<Env, A>> ma) Source #

Monadic join

method ReaderResult<A> Run <Env, A> (this Reader<Env, A> self, Env env) Source #

Runs the Reader monad and memoizes the result in a TryOption monad. Use Match, IfSucc, IfNone, etc to extract.

method Reader<Env, Seq<A>> AsEnumerable <Env, A> (this Reader<Env, A> self) Source #

method Seq<A> ToSeq <Env, A> (this Reader<Env, A> self, Env env) Source #

method Lst<A> ToList <Env, A> (this Reader<Env, A> self, Env env) Source #

method Option<A> ToOption <Env, A> (this Reader<Env, A> self, Env env) Source #

method OptionUnsafe<A> ToOptionUnsafe <Env, A> (this Reader<Env, A> self, Env env) Source #

method OptionAsync<A> ToOptionAsync <Env, A> (this Reader<Env, A> self, Env env) Source #

method Either<Error, A> ToEither <Env, A> (this Reader<Env, A> self, Env env) Source #

method Either<L, A> ToEither <Env, L, A> (this Reader<Env, A> self, Env env, Func<Error, L> Left) Source #

method EitherUnsafe<Error, A> ToEitherUnsafe <Env, A> (this Reader<Env, A> self, Env env) Source #

method EitherUnsafe<L, A> ToEitherUnsafe <Env, L, A> (this Reader<Env, A> self, Env env, Func<Error, L> Left) Source #

method EitherAsync<Error, A> ToEitherAsync <Env, A> (this Reader<Env, A> self, Env env) Source #

method EitherAsync<L, A> ToEitherAsync <Env, L, A> (this Reader<Env, A> self, Env env, Func<Error, L> Left) Source #

method Try<A> ToTry <Env, A> (this Reader<Env, A> self, Env env) Source #

method TryAsync<A> ToTryAsync <Env, A> (this Reader<Env, A> self, Env env) Source #

method IEnumerable<A> AsEnumerable <Env, A> (this Reader<Env, A> self, Env env) Source #

method Reader<Env, Unit> Iter <Env, A> (this Reader<Env, A> self, Action<A> action) Source #

method Reader<Env, int> Count <Env, T> (this Reader<Env, T> self) Source #

method Reader<Env, int> Sum <Env> (this Reader<Env, int> self) Source #

method Reader<Env, bool> ForAll <Env, A> (this Reader<Env, A> self, Func<A, bool> pred) Source #

method Reader<Env, bool> Exists <Env, A> (this Reader<Env, A> self, Func<A, bool> pred) Source #

method Reader<Env, S> Fold <Env, S, A> (this Reader<Env, A> self, S state, Func<S, A, S> folder) Source #

method Reader<Env, R> Map <Env, A, R> (this Reader<Env, A> self, Func<A, R> mapper) Source #

method Reader<Env, A> Strict <Env, A> (this Reader<Env, A> ma) Source #

Force evaluation of the monad (once only)

method Reader<Env, A> Do <Env, A> (this Reader<Env, A> ma, Action<A> f) Source #

Impure iteration of the bound value in the structure

Parameters

returns

Returns the original unmodified structure

method Reader<Env, B> Bind <Env, A, B> (this Reader<Env, A> self, Func<A, Reader<Env, B>> binder) Source #

method Reader<Env, B> Select <Env, A, B> (this Reader<Env, A> self, Func<A, B> map) Source #

Select

method Reader<Env, C> SelectMany <Env, A, B, C> ( this Reader<Env, A> self, Func<A, Reader<Env, B>> bind, Func<A, B, C> project) Source #

Select Many

method Reader<Env, Env> Fold <Env, A> (this Reader<Env, A> self, Func<Env, A, Env> f) Source #

class Prelude Source #

Methods

method Reader<Env, A> flatten <Env, A> (Reader<Env, Reader<Env, A>> ma) Source #

Monadic join

method Reader<Env, A> Reader <Env, A> (A value) Source #

Reader monad constructor

Parameters

type Env

Environment

type A

Wrapped type

param value

Wrapped value

returns

Reader monad

method Reader<Env, A> Reader <Env, A> (Func<Env, A> f) Source #

Reader monad constructor

Parameters

type Env

Environment

type A

Wrapped type

param value

Wrapped value

returns

Reader monad

method Reader<Env, A> ReaderFail <Env, A> (string error) Source #

Reader failure

method Reader<Env, A> ReaderFail <Env, A> (int code, string error) Source #

Reader failure

method Reader<Env, A> ReaderFail <Env, A> (string error, Exception exception) Source #

Reader failure

method Reader<Env, A> ReaderFail <Env, A> (Exception exception) Source #

Reader failure

method Reader<Env, Env> ask <Env> () Source #

Retrieves the reader monad environment.

Parameters

type Env

Environment

returns

Reader monad with the environment in as the bound value

method Reader<Env, R> asks <Env, R> (Func<Env, R> f) Source #

Retrieves a function of the current environment.

Parameters

type Env

Environment

type R

Bound and mapped value type

returns

Reader monad with the mapped environment in as the bound value

method Reader<Env, A> local <Env, A> (Reader<Env, A> ma, Func<Env, Env> f) Source #

Executes a computation in a modified environment

Parameters

param f

The function to modify the environment.

param m

Reader to modify

returns

Modified reader

method Reader<Env, Option<A>> choose <Env, A> (params Reader<Env, Option<A>>[] monads) Source #

Chooses the first monad result that has a Some(x) for the value

method Reader<Env, A> tryread <Env, A> (Reader<Env, A> m) Source #

Run the reader and catch exceptions

method Try<Reader<Env, A>> tryfun <Env, A> (Reader<Env, A> ma) Source #