# NumType<SELF, NUM, A, PRED> Class

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

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

DECLARATION
[Serializable]
public abstract class NumType<SELF, NUM, A, PRED> : IEquatable<SELF>,
IComparable<SELF>
NAMESPACE
LanguageExt

## Constructors

NumType(A)
SUMMARY

Constructor

PARAMETERS
value
A
Value to bind
DECLARATION
public ctor NumType(A value)
EXCEPTIONS
ArgumentOutOfRangeException
If argument fails to pass the predicate provided in the generic argument PRED
ArgumentNullException
Null values are not accepted

## Fields

New
SUMMARY

Constructor function

DECLARATION
public static readonly Func<A, SELF> New
Value
DECLARATION

## Methods

Abs()
SUMMARY

Find the absolute value of a number

DECLARATION
public virtual SELF Abs()
RETURNS
SELF
The non-negative absolute value of x
Bind(Func<A, SELF>)
SUMMARY

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

PARAMETERS
bind
Func<A, SELF>
Bind function
DECLARATION
[Pure]
public virtual SELF Bind(Func<A, SELF> bind)
RETURNS
SELF
CompareTo(SELF)
PARAMETERS
other
SELF
DECLARATION
[Pure]
public virtual int CompareTo(SELF other)
RETURNS
int
Divide(SELF)
SUMMARY

Divide NewType(x) and NewType(y)

PARAMETERS
rhs
SELF
Right-hand side of the operation
DECLARATION
[Pure]
public virtual SELF Divide(SELF rhs)
RETURNS
SELF
lhs / rhs
Equals(SELF)
PARAMETERS
other
SELF
DECLARATION
[Pure]
public virtual bool Equals(SELF other)
RETURNS
bool
Equals(SELF, SELF)
PARAMETERS
other
SELF
epsilon
SELF
DECLARATION
[Pure]
public virtual bool Equals(SELF other, SELF epsilon)
RETURNS
bool
Equals(object)
PARAMETERS
obj
object
DECLARATION
[Pure]
public override bool Equals(object obj)
RETURNS
bool
Exists(Func<A, bool>)
SUMMARY

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

PARAMETERS
predicate
Func<A, bool>
DECLARATION
[Pure]
public virtual bool Exists(Func<A, bool> predicate)
RETURNS
bool
Fold<S>(S, Func<S, A, S>)
SUMMARY

Fold

PARAMETERS
state
S
Initial state
folder
Func<S, A, S>
Fold function
DECLARATION
public virtual S Fold<S>(S state, Func<S, A, S> folder)
RETURNS
S
Folded state and NumType bound value
FoldBack<S>(S, Func<S, A, S>)
SUMMARY

Fold back

PARAMETERS
state
S
Initial state
folder
Func<S, A, S>
Fold function
DECLARATION
public virtual S FoldBack<S>(S state, Func<S, A, S> folder)
RETURNS
S
Folded state and NumType bound value
ForAll(Func<A, bool>)
SUMMARY

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

PARAMETERS
predicate
Func<A, bool>
DECLARATION
[Pure]
public virtual bool ForAll(Func<A, bool> predicate)
RETURNS
bool
FromInteger(int)
PARAMETERS
value
int
DECLARATION
[Pure]
public static SELF FromInteger(int value)
RETURNS
SELF
GetHashCode()
DECLARATION
[Pure]
public override int GetHashCode()
RETURNS
int
Iter(Action<A>)
SUMMARY

Invoke an action that takes the bound value as an argument

PARAMETERS
f
Action<A>
Action to invoke
DECLARATION
public virtual Unit Iter(Action<A> f)
Map(Func<A, A>)
SUMMARY

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

PARAMETERS
map
Func<A, A>
DECLARATION
[Pure]
public virtual SELF Map(Func<A, A> map)
RETURNS
SELF
Max(SELF)
PARAMETERS
rhs
SELF
DECLARATION
public virtual SELF Max(SELF rhs)
RETURNS
SELF
Min(SELF)
PARAMETERS
rhs
SELF
DECLARATION
public virtual SELF Min(SELF rhs)
RETURNS
SELF
Plus(SELF)
SUMMARY

Sum of NumType(x) and NumType(y)

PARAMETERS
rhs
SELF
Right-hand side of the operation
DECLARATION
[Pure]
public virtual SELF Plus(SELF rhs)
RETURNS
SELF
lhs + rhs
Product(SELF)
SUMMARY

Multiply NewType(x) and NewType(y)

PARAMETERS
rhs
SELF
Right-hand side of the operation
DECLARATION
[Pure]
public virtual SELF Product(SELF rhs)
RETURNS
SELF
lhs * rhs
Select(Func<A, A>)
SUMMARY

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

PARAMETERS
map
Func<A, A>
DECLARATION
[Pure]
public virtual SELF Select(Func<A, A> map)
RETURNS
SELF
SelectMany(Func<A, NumType<SELF, NUM, A, PRED>>, Func<A, A, A>)
SUMMARY

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

PARAMETERS
bind
Func<A, NumType<SELF, NUM, A, PRED>>
Bind function
project
Func<A, A, A>
Final projection (select)
DECLARATION
[Pure]
public virtual SELF SelectMany(Func<A, NumType<SELF, NUM, A, PRED>> bind, Func<A, A, A> project)
RETURNS
SELF
Signum()
SUMMARY

Find the sign of x

DECLARATION
public virtual SELF Signum()
RETURNS
SELF
-1, 0, or +1
Subtract(SELF)
SUMMARY

Subtract of NewType(x) and NewType(y)

PARAMETERS
rhs
SELF
Right-hand side of the operation
DECLARATION
[Pure]
public virtual SELF Subtract(SELF rhs)
RETURNS
SELF
lhs - rhs
Sum()
SUMMARY

Sum

DECLARATION
public virtual A Sum()
RETURNS
A
ToString()
SUMMARY

Generate a text representation of the NumType and value

DECLARATION
[Pure]
public override string ToString()
RETURNS
string