LanguageExt.Core

LanguageExt.Core DataTypes New Types NumType

Contents

class NumType <SELF, NUM, A> Source #

where NUM : Num<A>
where SELF : NumType<SELF, NUM, A>

NumType - inspired by Haskell's 'newtype' keyword. This is setup for numeric types,and expects a Num class-instance as an argument (TInt, TDouble, etc.)

wiki.haskell.org/Newtype

Derive type from this one to get: Equatable, Comparable, Appendable, Foldable, Functor, Iterable: strongly typed values.

For example:

class Metres : NumType<Metres, TDouble, double> { public Metres(double x) : base(x) {} }

Will not accept null values

Parameters

type SELF

Self reference type - i.e. class Metres : NumType<Metres, ... >

type NUM

Num of A, e.g. TInt, TDouble, TFloat, etc.

type A

Bound value type

Constructors

constructor NumType (A value) Source #

Constructor

Parameters

param value

Value to bind

Methods

method void GetObjectData (SerializationInfo info, StreamingContext context) Source #

class NumTypeExtensions Source #

Methods

method SELF Sum <SELF, NUM, A> (this IEnumerable<NumType<SELF, NUM, A>> self) Source #

where SELF : NumType<SELF, NUM, A>
where NUM : Num<A>

method SELF Sum <SELF, NUM, A, PRED> (this IEnumerable<NumType<SELF, NUM, A, PRED>> self) Source #

where SELF : NumType<SELF, NUM, A, PRED>
where NUM : Num<A>
where PRED : Pred<A>

class NumType <SELF, NUM, A, PRED> Source #

where NUM : Num<A>
where PRED : Pred<A>
where SELF : NumType<SELF, NUM, A, PRED>

NumType - inspired by Haskell's 'newtype' keyword. This is setup for numeric types,and expects a Num class-instance as an argument (TInt, TDouble, etc.)

wiki.haskell.org/Newtype

Derive type from this one to get: Equatable, Comparable, Appendable, Foldable, Functor, Iterable: strongly typed values.

For example:

class Metres : NumType<Metres, TDouble, double> { public Metres(double x) : base(x) {} }

Will not accept null values

Parameters

type SELF

Self reference type - i.e. class Metres : NumType<Metres, ... >

type NUM

Num of A, e.g. TInt, TDouble, TFloat, etc.

type A

Bound value type

type PRED

A predicate to be applied to the value passed into the constructor. Allows for constraints on the value stored.

Fields

field A Value Source #

field Func<A, SELF> New = IL.Ctor<A, SELF>() Source #

Constructor function

Constructors

constructor NumType (A value) Source #

Constructor

Parameters

param value

Value to bind

Methods

method Fin<SELF> NewTry (A value) Source #

Try new

method Option<SELF> NewOption (A value) Source #

Optional new

method void GetObjectData (SerializationInfo info, StreamingContext context) Source #

method SELF Plus (SELF rhs) Source #

Sum of NumType(x) and NumType(y)

Parameters

param rhs

Right-hand side of the operation

returns

lhs + rhs

method SELF Subtract (SELF rhs) Source #

Subtract of NewType(x) and NewType(y)

Parameters

param rhs

Right-hand side of the operation

returns

lhs - rhs

method SELF Divide (SELF rhs) Source #

Divide NewType(x) and NewType(y)

Parameters

param rhs

Right-hand side of the operation

returns

lhs / rhs

method SELF Product (SELF rhs) Source #

Multiply NewType(x) and NewType(y)

Parameters

param rhs

Right-hand side of the operation

returns

lhs * rhs

method SELF Abs () Source #

Find the absolute value of a number

Parameters

param x

The value to find the absolute value of

returns

The non-negative absolute value of x

method SELF Signum () Source #

Find the sign of x

Parameters

param x

The value to find the sign of

returns

-1, 0, or +1

method SELF Min (SELF rhs) Source #

method SELF Max (SELF rhs) Source #

method int CompareTo (SELF? other) Source #

method bool Equals (SELF? other) Source #

method bool Equals (SELF other, SELF epsilon) Source #

method bool Equals (object? obj) Source #

method int GetHashCode () Source #

method int CompareTo (object? obj) Source #

method SELF Bind (Func<A, SELF> bind) Source #

Monadic bind of the bound value to a new value of the same type

Parameters

param bind

Bind function

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

Run a predicate for all values in the NumType (only ever one)

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

Run a predicate for all values in the NumType (only ever one)

method SELF Map (Func<A, A> map) Source #

Map the bound value to a new value of the same type

method SELF Select (Func<A, A> map) Source #

Map the bound value to a new value of the same type

method SELF SelectMany ( Func<A, NumType<SELF, NUM, A, PRED>> bind, Func<A, A, A> project) Source #

Monadic bind of the bound value to a new value of the same type

Parameters

param bind

Bind function

param project

Final projection (select)

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

Invoke an action that takes the bound value as an argument

Parameters

param f

Action to invoke

method string ToString () Source #

Generate a text representation of the NumType and value

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

Fold

Parameters

type S

State type

param state

Initial state

param folder

Fold function

returns

Folded state and NumType bound value

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

Fold back

Parameters

type S

State type

param state

Initial state

param folder

Fold function

returns

Folded state and NumType bound value

method A Sum () Source #

Sum

method SELF FromInteger (int value) Source #

Operators

operator - (NumType<SELF, NUM, A, PRED> x) Source #

operator + (NumType<SELF, NUM, A, PRED> lhs, NumType<SELF, NUM, A, PRED> rhs) Source #

operator - (NumType<SELF, NUM, A, PRED> lhs, NumType<SELF, NUM, A, PRED> rhs) Source #

operator * (NumType<SELF, NUM, A, PRED> lhs, NumType<SELF, NUM, A, PRED> rhs) Source #

operator / (NumType<SELF, NUM, A, PRED> lhs, NumType<SELF, NUM, A, PRED> rhs) Source #

operator == (NumType<SELF, NUM, A, PRED> lhs, NumType<SELF, NUM, A, PRED> rhs) Source #

operator != (NumType<SELF, NUM, A, PRED> lhs, NumType<SELF, NUM, A, PRED> rhs) Source #

operator > (NumType<SELF, NUM, A, PRED> lhs, NumType<SELF, NUM, A, PRED> rhs) Source #

operator >= (NumType<SELF, NUM, A, PRED> lhs, NumType<SELF, NUM, A, PRED> rhs) Source #

operator < (NumType<SELF, NUM, A, PRED> lhs, NumType<SELF, NUM, A, PRED> rhs) Source #

operator <= (NumType<SELF, NUM, A, PRED> lhs, NumType<SELF, NUM, A, PRED> rhs) Source #

class Prelude Source #

Methods

method NUMTYPE bind <NUMTYPE, NUM, T, PRED> (NumType<NUMTYPE, NUM, T, PRED> value, Func<T, NUMTYPE> bind) Source #

where NUM : Num<T>
where PRED : Pred<T>
where NUMTYPE : NumType<NUMTYPE, NUM, T, PRED>

method Unit iter <NUMTYPE, NUM, T, PRED> (NumType<NUMTYPE, NUM, T, PRED> value, Action<T> f) Source #

where NUM : Num<T>
where PRED : Pred<T>
where NUMTYPE : NumType<NUMTYPE, NUM, T, PRED>

method int count <NUMTYPE, NUM, T, PRED> (NumType<NUMTYPE, NUM, T, PRED> value) Source #

where NUM : Num<T>
where PRED : Pred<T>
where NUMTYPE : NumType<NUMTYPE, NUM, T, PRED>

method bool exists <NUMTYPE, NUM, T, PRED> (NumType<NUMTYPE, NUM, T, PRED> value, Func<T, bool> predicate) Source #

where NUM : Num<T>
where PRED : Pred<T>
where NUMTYPE : NumType<NUMTYPE, NUM, T, PRED>

method bool forall <NUMTYPE, NUM, T, PRED> (NumType<NUMTYPE, NUM, T, PRED> value, Func<T, bool> predicate) Source #

where NUM : Num<T>
where PRED : Pred<T>
where NUMTYPE : NumType<NUMTYPE, NUM, T, PRED>

method NUMTYPE map <NUMTYPE, NUM, T, PRED> (NumType<NUMTYPE, NUM, T, PRED> value, Func<T, T> map) Source #

where NUM : Num<T>
where PRED : Pred<T>
where NUMTYPE : NumType<NUMTYPE, NUM, T, PRED>

method NUMTYPE add <NUMTYPE, NUM, A, PRED> (NumType<NUMTYPE, NUM, A, PRED> x, NUMTYPE y) Source #

where NUM : Num<A>
where PRED : Pred<A>
where NUMTYPE : NumType<NUMTYPE, NUM, A, PRED>

Add the bound values of x and y, uses an Add trait to provide the add operation for type A. For example x.Add<Metres, TInt, int>(y)

Parameters

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

An NewType with y added to x

method NUMTYPE subtract <NUMTYPE, NUM, A, PRED> (NumType<NUMTYPE, NUM, A, PRED> x, NUMTYPE y) Source #

where NUM : Num<A>
where PRED : Pred<A>
where NUMTYPE : NumType<NUMTYPE, NUM, A, PRED>

Find the subtract between the two bound values of x and y, uses a Subtract trait to provide the subtract operation for type A. For example x.Subtract<TInteger,int>(y)

Parameters

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

An NewType with the subtract between x and y

method NUMTYPE product <NUMTYPE, NUM, A, PRED> (NumType<NUMTYPE, NUM, A, PRED> x, NUMTYPE y) Source #

where NUM : Num<A>
where PRED : Pred<A>
where NUMTYPE : NumType<NUMTYPE, NUM, A, PRED>

Find the product between the two bound values of x and y, uses a Product trait to provide the product operation for type A. For example x.Product<TInteger,int>(y)

Parameters

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

Product of x and y

method NUMTYPE divide <NUMTYPE, NUM, A, PRED> (NumType<NUMTYPE, NUM, A, PRED> x, NUMTYPE y) Source #

where NUM : Num<A>
where PRED : Pred<A>
where NUMTYPE : NumType<NUMTYPE, NUM, A, PRED>

Find the product between the two bound values of x and y, uses a Product trait to provide the product operation for type A. For example x.Product<TInteger,int>(y)

Parameters

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

Product of x and y

method A sum <NUMTYPE, NUM, A, PRED> (NumType<NUMTYPE, NUM, A, PRED> self) Source #

where NUMTYPE : NumType<NUMTYPE, NUM, A, PRED>
where PRED : Pred<A>
where NUM : Num<A>

method NUMTYPE bind <NUMTYPE, NUM, T> (NumType<NUMTYPE, NUM, T> value, Func<T, NUMTYPE> bind) Source #

where NUM : Num<T>
where NUMTYPE : NumType<NUMTYPE, NUM, T>

method Unit iter <NUMTYPE, NUM, T> (NumType<NUMTYPE, NUM, T> value, Action<T> f) Source #

where NUM : Num<T>
where NUMTYPE : NumType<NUMTYPE, NUM, T>

method int count <NUMTYPE, NUM, T> (NumType<NUMTYPE, NUM, T> value) Source #

where NUM : Num<T>
where NUMTYPE : NumType<NUMTYPE, NUM, T>

method bool exists <NUMTYPE, NUM, T> (NumType<NUMTYPE, NUM, T> value, Func<T, bool> predicate) Source #

where NUM : Num<T>
where NUMTYPE : NumType<NUMTYPE, NUM, T>

method bool forall <NUMTYPE, NUM, T> (NumType<NUMTYPE, NUM, T> value, Func<T, bool> predicate) Source #

where NUM : Num<T>
where NUMTYPE : NumType<NUMTYPE, NUM, T>

method NUMTYPE map <NUMTYPE, NUM, T> (NumType<NUMTYPE, NUM, T> value, Func<T, T> map) Source #

where NUM : Num<T>
where NUMTYPE : NumType<NUMTYPE, NUM, T>

method NUMTYPE add <NUMTYPE, NUM, A> (NumType<NUMTYPE, NUM, A> x, NUMTYPE y) Source #

where NUM : Num<A>
where NUMTYPE : NumType<NUMTYPE, NUM, A>

Add the bound values of x and y, uses an Add trait to provide the add operation for type A. For example x.Add<Metres, TInt, int>(y)

Parameters

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

An NewType with y added to x

method NUMTYPE subtract <NUMTYPE, NUM, A> (NumType<NUMTYPE, NUM, A> x, NUMTYPE y) Source #

where NUM : Num<A>
where NUMTYPE : NumType<NUMTYPE, NUM, A>

Find the subtract between the two bound values of x and y, uses a Subtract trait to provide the subtract operation for type A. For example x.Subtract<TInteger,int>(y)

Parameters

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

An NewType with the subtract between x and y

method NUMTYPE product <NUMTYPE, NUM, A> (NumType<NUMTYPE, NUM, A> x, NUMTYPE y) Source #

where NUM : Num<A>
where NUMTYPE : NumType<NUMTYPE, NUM, A>

Find the product between the two bound values of x and y, uses a Product trait to provide the product operation for type A. For example x.Product<TInteger,int>(y)

Parameters

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

Product of x and y

method NUMTYPE divide <NUMTYPE, NUM, A> (NumType<NUMTYPE, NUM, A> x, NUMTYPE y) Source #

where NUM : Num<A>
where NUMTYPE : NumType<NUMTYPE, NUM, A>

Find the product between the two bound values of x and y, uses a Product trait to provide the product operation for type A. For example x.Product<TInteger,int>(y)

Parameters

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

Product of x and y

method A sum <NUMTYPE, NUM, A> (NumType<NUMTYPE, NUM, A> self) Source #

where NUMTYPE : NumType<NUMTYPE, NUM, A>
where NUM : Num<A>