LanguageExt.Core

LanguageExt.Core Concurrency AtomSeq

Contents

class AtomSeq <A> Source #

Atoms provide a way to manage shared, synchronous, independent state without locks. AtomSeq wraps the language-ext Seq, and makes sure all operations are atomic and thread-safe without resorting to locking

See the concurrency section of the wiki for more info.

Parameters

type A

Item value type

Indexers

this [ A ] Source #

Indexer

Properties

property AtomSeq<A> Empty Source #

Empty sequence

property object? Case Source #

Reference version for use in pattern-matching

property A Head Source #

Head item in the sequence. NOTE: If IsEmpty is true then Head is undefined. Call HeadOrNone() if for maximum safety.

property Seq<A> Tail Source #

Tail of the sequence

property Seq<A> Init Source #

Get all items except the last one

property A Last Source #

Last item in sequence. Throws if no items in sequence

property bool IsEmpty Source #

Returns true if the sequence is empty

For lazy streams this will have to peek at the first item. So, the first item will be consumed.

property int Count Source #

Returns the number of items in the sequence

Parameters

returns

Number of items in the sequence

property int Length Source #

Alias of Count

Parameters

returns

Number of items in the sequence

property Seq<Seq<A>> Inits Source #

Returns all initial segments of the sequence, shortest first

Including the empty sequence

Parameters

returns

Initial segments of the sequence

Examples

 Seq("a", "b", "c").Inits

 > Seq(Seq(), Seq("a"), Seq("a", "b"), Seq("a", "b", "c"))

property Seq<Seq<A>> NonEmptyInits Source #

Returns all initial segments of the sequence, shortest first.

Not including the empty sequence

Parameters

returns

Initial segments of the sequence

Examples

 Seq("a", "b", "c").Inits

 > Seq(Seq("a"), Seq("a", "b"), Seq("a", "b", "c"))

property Seq<Seq<A>> Tails Source #

Returns all final segments of the argument, longest first.

Including the empty sequence

Parameters

returns

Initial segments of the sequence

Examples

 Seq("a", "b", "c").Tails

 > Seq(Seq("a", "b", "c"), Seq("a", "b"), Seq("a"), Seq())

property Seq<Seq<A>> NonEmptyTails Source #

Returns all final segments of the argument, longest first.

Not including the empty sequence

Parameters

returns

Initial segments of the sequence

Examples

 Seq("a", "b", "c").Tails

 > Seq(Seq("a", "b", "c"), Seq("a", "b"), Seq("a"))

Constructors

constructor AtomSeq (IEnumerable<A> ma) Source #

Constructor from lazy sequence

Methods

method Seq<A> ToSeq () Source #

Convert to an immutable sequence

This is effectively a zero cost operation, not even a single allocation

method void Deconstruct (out A head, out Seq<A> tail) Source #

method Unit Swap (Func<Seq<A>, Seq<A>> swap) Source #

Atomically swap the underlying Seq. Allows for multiple operations on the Seq in an entirely transactional and atomic way.

Any functions passed as arguments may be run multiple times if there are multiple threads competing to update this data structure. Therefore the functions must spend as little time performing the injected behaviours as possible to avoid repeated attempts

Parameters

param swap

Swap function, maps the current state of the AtomSeq to a new state

method Unit Add (A value) Source #

Add an item to the end of the sequence

Forces evaluation of the entire lazy sequence so the item can be appended

method Unit Concat (IEnumerable<A> items) Source #

Add a range of items to the end of the sequence

Forces evaluation of the entire lazy sequence so the items can be appended.

method Unit Concat (Lst<A> items) Source #

Add a range of items to the end of the sequence

Forces evaluation of the entire lazy sequence so the items can be appended.

method Unit Concat (Set<A> items) Source #

Add a range of items to the end of the sequence

Forces evaluation of the entire lazy sequence so the items can be appended.

method Unit Concat (HashSet<A> items) Source #

Add a range of items to the end of the sequence

Forces evaluation of the entire lazy sequence so the items can be appended.

method Unit Concat (Arr<A> items) Source #

Add a range of items to the end of the sequence

Forces evaluation of the entire lazy sequence so the items can be appended.

method Unit Concat (Stck<A> items) Source #

Add a range of items to the end of the sequence

Forces evaluation of the entire lazy sequence so the items can be appended.

method Unit Concat (IReadOnlyCollection<A> items) Source #

Add a range of items to the end of the sequence

Forces evaluation of the entire lazy sequence so the items can be appended.

method Unit Concat (Seq<A> rhs) Source #

Add a range of items to the end of the sequence

Forces evaluation of the entire lazy sequence so the items can be appended.

method Option<A> HeadOrNone () Source #

Head of the sequence if this node isn't the empty node

method Option<A> LastOrNone () Source #

Last item in sequence.

method Either<L, A> LastOrLeft <L> (L Left) Source #

Last item in sequence.

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

Last item in sequence.

method Validation<F, A> LastOrInvalid <F> (F Fail) Source #

Last item in sequence.

method Validation<F, A> LastOrInvalid <F> (Func<F> Fail) Source #

Last item in sequence.

method Validation<MonoidFail, F, A> LastOrInvalid <MonoidFail, F> (F Fail) Source #

where MonoidFail : struct, Monoid<F>, Eq<F>

Last item in sequence.

method Validation<MonoidFail, F, A> LastOrInvalid <MonoidFail, F> (Func<F> Fail) Source #

where MonoidFail : struct, Monoid<F>, Eq<F>

Last item in sequence.

method Validation<Fail, A> HeadOrInvalid <Fail> (Fail fail) Source #

Head of the sequence if this node isn't the empty node or fail

Parameters

type Fail
param fail

Fail case

returns

Head of the sequence or fail

method Validation<MonoidFail, Fail, A> HeadOrInvalid <MonoidFail, Fail> (Fail fail) Source #

where MonoidFail : struct, Monoid<Fail>, Eq<Fail>

Head of the sequence

method Either<L, A> HeadOrLeft <L> (L left) Source #

Head of the sequence if this node isn't the empty node or left

Parameters

type L
param left

Left case

returns

Head of the sequence or left

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

Head of the sequence if this node isn't the empty node

method IEnumerable<A> AsEnumerable () Source #

Stream as an enumerable

method B Match <B> (Func<B> Empty, Func<A, Seq<A>, B> Tail) Source #

Match empty sequence, or multi-item sequence

Parameters

type B

Return value type

param Empty

Match for an empty list

param Tail

Match for a non-empty

returns

Result of match function invoked

method B Match <B> ( Func<B> Empty, Func<A, B> Head, Func<A, Seq<A>, B> Tail) Source #

Match empty sequence, or one item sequence, or multi-item sequence

Parameters

type B

Return value type

param Empty

Match for an empty list

param Tail

Match for a non-empty

returns

Result of match function invoked

method B Match <B> ( Func<B> Empty, Func<Seq<A>, B> Seq) Source #

Match empty sequence, or multi-item sequence

Parameters

type B

Return value type

param Empty

Match for an empty list

param Sequence

Match for a non-empty

returns

Result of match function invoked

method B Match <B> ( Func<B> Empty, Func<A, B> Head, Func<Seq<A>, B> Tail) Source #

Match empty sequence, or one item sequence, or multi-item sequence

Parameters

type B

Return value type

param Empty

Match for an empty list

param Tail

Match for a non-empty

returns

Result of match function invoked

method Unit Iter (Action<A> f) Source #

Impure iteration of the bound values in the structure

Parameters

returns

Returns the original unmodified structure

method Seq<B> Map <B> (Func<A, B> f) Source #

Map the sequence using the function provided

Parameters

type B
param f

Mapping function

returns

Mapped sequence

method Unit MapInPlace (Func<A, A> f) Source #

Map the sequence using the function provided

Any functions passed as arguments may be run multiple times if there are multiple threads competing to update this data structure. Therefore the functions must spend as little time performing the injected behaviours as possible to avoid repeated attempts

Parameters

type B
param f

Mapping function

returns

Mapped sequence

method Seq<B> Select <B> (Func<A, B> f) Source #

Map the sequence using the function provided

Parameters

type B
param f

Mapping function

returns

Mapped sequence

method Seq<B> Bind <B> (Func<A, Seq<B>> f) Source #

Monadic bind (flatmap) of the sequence

Parameters

type B

Bound return value type

param f

Bind function

returns

Flatmapped sequence

method Unit BindInPlace <B> (Func<A, Seq<A>> f) Source #

Monadic bind (flatmap) of the sequence

Any functions passed as arguments may be run multiple times if there are multiple threads competing to update this data structure. Therefore the functions must spend as little time performing the injected behaviours as possible to avoid repeated attempts

Parameters

type B

Bound return value type

param f

Bind function

returns

Flat-mapped sequence

method Seq<C> SelectMany <B, C> (Func<A, Seq<B>> bind, Func<A, B, C> project) Source #

Monadic bind (flatmap) of the sequence

Parameters

type B

Bound return value type

param bind

Bind function

returns

Flatmapped sequence

method Seq<A> Filter (Func<A, bool> f) Source #

Filter the items in the sequence

Parameters

param f

Predicate to apply to the items

returns

Filtered sequence

method Unit FilterInPlace (Func<A, bool> f) Source #

Filter the items in the sequence

Any functions passed as arguments may be run multiple times if there are multiple threads competing to update this data structure. Therefore the functions must spend as little time performing the injected behaviours as possible to avoid repeated attempts

Parameters

param f

Predicate to apply to the items

returns

Filtered sequence

method Seq<A> Where (Func<A, bool> f) Source #

Filter the items in the sequence

Parameters

param f

Predicate to apply to the items

returns

Filtered sequence

method S Fold <S> (S state, Func<S, A, S> f) Source #

Fold the sequence from the first item to the last

Parameters

type S

State type

param state

Initial state

param f

Fold function

returns

Aggregated state

method S FoldBack <S> (S state, Func<S, A, S> f) Source #

Fold the sequence from the last item to the first. For sequences that are not lazy and are less than 5000 items long, FoldBackRec is called instead, because it is faster.

Parameters

type S

State type

param state

Initial state

param f

Fold function

returns

Aggregated state

method bool Exists (Func<A, bool> f) Source #

Returns true if the supplied predicate returns true for any item in the sequence. False otherwise.

Parameters

param f

Predicate to apply

returns

True if the supplied predicate returns true for any item in the sequence. False otherwise.

method bool ForAll (Func<A, bool> f) Source #

Returns true if the supplied predicate returns true for all items in the sequence. False otherwise. If there is an empty sequence then true is returned.

Parameters

param f

Predicate to apply

returns

True if the supplied predicate returns true for all items in the sequence. False otherwise. If there is an empty sequence then true is returned.

method bool Any () Source #

Returns true if the sequence has items in it

Parameters

returns

True if the sequence has items in it

method Unit Intersperse (A value) Source #

Inject a value in between each item in the sequence

Parameters

type A

Bound type

param ma

Sequence to inject values into

param value

Item to inject

returns

A sequence with the values injected

method int GetHashCode () Source #

Get the hash code for all of the items in the sequence, or 0 if empty

Parameters

returns

method int CompareTo (object? obj) Source #

method string ToString () Source #

Format the collection as [a, b, c, ...] The elipsis is used for collections over 50 items To get a formatted string with all the items, use ToFullString or ToFullArrayString.

method string ToFullString (string separator = ", ") Source #

Format the collection as a, b, c, ...

method string ToFullArrayString (string separator = ", ") Source #

Format the collection as [a, b, c, ...]

method bool Equals (object? obj) Source #

Equality test

method bool Equals (Seq<A> rhs) Source #

Equality test

method bool Equals (AtomSeq<A>? rhs) Source #

Equality test

method bool Equals <EqA> (Seq<A> rhs) Source #

where EqA : struct, Eq<A>

Equality test

method bool Equals <EqA> (AtomSeq<A> rhs) Source #

where EqA : struct, Eq<A>

Equality test

method Unit Skip (int amount) Source #

Skip count items

method Unit Take (int amount) Source #

Take count items

method Unit TakeWhile (Func<A, bool> pred) Source #

Iterate the sequence, yielding items if they match the predicate provided, and stopping as soon as one doesn't

Any functions passed as arguments may be run multiple times if there are multiple threads competing to update this data structure. Therefore the functions must spend as little time performing the injected behaviours as possible to avoid repeated attempts

Parameters

returns

A new sequence with the first items that match the predicate

method Unit TakeWhile (Func<A, int, bool> pred) Source #

Iterate the sequence, yielding items if they match the predicate provided, and stopping as soon as one doesn't. An index value is also provided to the predicate function.

Any functions passed as arguments may be run multiple times if there are multiple threads competing to update this data structure. Therefore the functions must spend as little time performing the injected behaviours as possible to avoid repeated attempts

Parameters

returns

A new sequence with the first items that match the predicate

method int CompareTo (Seq<A> rhs) Source #

Compare to another sequence

method int CompareTo (AtomSeq<A>? rhs) Source #

Compare to another sequence

method int CompareTo <OrdA> (Seq<A> rhs) Source #

where OrdA : struct, Ord<A>

Compare to another sequence

method int CompareTo <OrdA> (AtomSeq<A> rhs) Source #

where OrdA : struct, Ord<A>

Compare to another sequence

method Unit Strict () Source #

Force all items lazy to stream

method IEnumerator<A> GetEnumerator () Source #

method Seq<B> Cast <B> () Source #

Operators

operator > (AtomSeq<A> x, AtomSeq<A> y) Source #

Ordering operator

operator >= (AtomSeq<A> x, AtomSeq<A> y) Source #

Ordering operator

operator < (AtomSeq<A> x, AtomSeq<A> y) Source #

Ordering operator

operator <= (AtomSeq<A> x, AtomSeq<A> y) Source #

Ordering operator

operator == (AtomSeq<A> x, AtomSeq<A> y) Source #

Equality operator

operator != (AtomSeq<A> x, AtomSeq<A> y) Source #

Non-equality operator