Identity

December 15, 2024 ยท View on GitHub

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.

ParamTypeDescription
vanyThe value to be wrapped by Identity. This cannot be undefined.

Identity.of(v)

Identity constructor.

ParamTypeDescription
vanyThe 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.

ParamTypeDescription
jIdentityThe 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.

ParamTypeDescription
pIdentityThe 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.

ParamTypeDescription
ffunctionFunction

Identity.chain(f)

Chains a computation that returns an Identity.

ParamTypeDescription
ffunctionFunction that returns another Identity

Identity.toString()

Returns a stringified version of the Identity.


Examples

TODO: Add some examples