LanguageExt.Core

LanguageExt.Core DataTypes New Types NewType

Contents

class NewType <NEWTYPE, A> Source #

where NEWTYPE : NewType<NEWTYPE, A>

NewType - inspired by Haskell's 'newtype' keyword. https://wiki.haskell.org/Newtype Derive type from this one to get: Equatable, Comparable, Appendable, Subtractable, Multiplicable, Divisible, Foldable, Functor, Interable: strongly typed values.

For example:

class Metres : NewType<Metres, double> { public Metres(double x) : base(x) {} }
class Hours : NewType<Hours, double> { public Hours(double x) : base(x) {} }

Will not accept null values

Parameters

type NEWTYPE

Implementing class

type A

Inner bound value type

Constructors

constructor NewType (A value) Source #

Constructor

Parameters

param value

Value to bind

Methods

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

class NewType <NEWTYPE, A, PRED> Source #

where PRED : Pred<A>
where NEWTYPE : NewType<NEWTYPE, A, PRED>

NewType - inspired by Haskell's 'newtype' keyword. https://wiki.haskell.org/Newtype Derive type from this one to get: Equatable, Comparable, Appendable, Subtractable, Multiplicable, Divisible, Foldable, Monadic, Functor, Interable: strongly typed values.

For example:

class Metres : NewType<Metres, double> { public Metres(double x) : base(x) {} }
class Hours : NewType<Hours, double> { public Hours(double x) : base(x) {} }

Will not accept null values

Parameters

type NEWTYPE

Implementing class

type A

Inner bound value type

type PRED

Predicate instance to run when the type is constructed

Constructors

constructor NewType (A value) Source #

Constructor

Parameters

param value

Value to bind

Methods

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

class NewType <NEWTYPE, A, PRED, ORD> Source #

where PRED : Pred<A>
where NEWTYPE : NewType<NEWTYPE, A, PRED, ORD>
where ORD : Ord<A>

NewType - inspired by Haskell's 'newtype' keyword. https://wiki.haskell.org/Newtype Derive type from this one to get: Equatable, Comparable, Appendable, Subtractable, Multiplicable, Divisible, Foldable, Monadic, Functor, Interable: strongly typed values.

For example:

class Metres : NewType<Metres, double> { public Metres(double x) : base(x) {} }
class Hours : NewType<Hours, double> { public Hours(double x) : base(x) {} }

Will not accept null values

Parameters

type NEWTYPE

Implementing class

type A

Inner bound value type

type PRED

Predicate instance to run when the type is constructed

type ORD

Ord<A> class instance

Fields

field A Value Source #

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

Constructor function

Constructors

constructor NewType (A value) Source #

Constructor

Parameters

param value

Value to bind

Methods

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

Optional new

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

Try new

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

method int CompareTo (NEWTYPE? other) Source #

method bool Equals (NEWTYPE? other) Source #

method bool Equals (object? obj) Source #

method int GetHashCode () Source #

method int CompareTo (object? obj) Source #

method NEWTYPE Bind (Func<A, NEWTYPE> 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 NewType (only ever one)

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

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

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

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

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

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

method NEWTYPE SelectMany ( Func<A, NewType<NEWTYPE, A, PRED, ORD>> 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 NewType 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 NewType 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 NewType bound value

Operators

operator == (NewType<NEWTYPE, A, PRED, ORD> lhs, NewType<NEWTYPE, A, PRED, ORD> rhs) Source #

operator != (NewType<NEWTYPE, A, PRED, ORD> lhs, NewType<NEWTYPE, A, PRED, ORD> rhs) Source #

operator > (NewType<NEWTYPE, A, PRED, ORD> lhs, NewType<NEWTYPE, A, PRED, ORD> rhs) Source #

operator >= (NewType<NEWTYPE, A, PRED, ORD> lhs, NewType<NEWTYPE, A, PRED, ORD> rhs) Source #

operator < (NewType<NEWTYPE, A, PRED, ORD> lhs, NewType<NEWTYPE, A, PRED, ORD> rhs) Source #

operator <= (NewType<NEWTYPE, A, PRED, ORD> lhs, NewType<NEWTYPE, A, PRED, ORD> rhs) Source #

class Prelude Source #

Methods

method NEWTYPE bind <NEWTYPE, T, PRED> (NewType<NEWTYPE, T, PRED> value, Func<T, NEWTYPE> bind) Source #

where PRED : Pred<T>
where NEWTYPE : NewType<NEWTYPE, T, PRED>

method Unit iter <NEWTYPE, T, PRED> (NewType<NEWTYPE, T, PRED> value, Action<T> f) Source #

where PRED : Pred<T>
where NEWTYPE : NewType<NEWTYPE, T, PRED>

method bool exists <NEWTYPE, T, PRED> (NewType<NEWTYPE, T, PRED> value, Func<T, bool> predicate) Source #

where PRED : Pred<T>
where NEWTYPE : NewType<NEWTYPE, T, PRED>

method bool forall <NEWTYPE, T, PRED> (NewType<NEWTYPE, T, PRED> value, Func<T, bool> predicate) Source #

where PRED : Pred<T>
where NEWTYPE : NewType<NEWTYPE, T, PRED>

method NEWTYPE map <NEWTYPE, T, PRED> (NewType<NEWTYPE, T, PRED> value, Func<T, T> map) Source #

where PRED : Pred<T>
where NEWTYPE : NewType<NEWTYPE, T, PRED>