Identity
An Identity is a wrapper for a value that cannot be changed. It is useful for handling pure values.
Implements: Monad, Semigroup, Setoid
Identity(v)
The Identity constructor.
Param | Type | Description |
---|---|---|
v | any |
The value to be wrapped by Identity. This cannot be undefined . |
Identity.of(v)
Identity constructor.
Param | Type | Description |
---|---|---|
v | any |
The value to be wrapped by Identity. This cannot be undefined . |
Identity.equals(j)
Checks if the value of the current Identity is equal to the value of the passed Identity. This uses strict equality (===
) to compare the values of the two Identities.
Param | Type | Description |
---|---|---|
j | Identity |
The Identity to compare with |
Identity.concat(p)
Concatenates the current Identity with the passed one. Note that the values of both Identities must be of the same type and must be of a type that supports the Semigroup
concatenation operation for this to work.
Param | Type | Description |
---|---|---|
p | Identity |
The Identity to concatenate with |
Identity.getValue()
Gets the value within the Identity.
Identity.map(f)
Applies the function to the value of the current Identity.
Param | Type | Description |
---|---|---|
f | function |
Function |
Identity.chain(f)
Chains a computation that returns an Identity.
Param | Type | Description |
---|---|---|
f | function |
Function that returns another Identity |
Identity.toString()
Returns a stringified version of the Identity.
Examples
TODO: Add some examples