Constructor
new Identity(value) → {RA.Identity}
- Source:
- Since:
- Implements:
- Apply, Applicative, Functor, Setoid, Semigroup, Chain, Monad, Ord, Monoid*, Contravariant
Private constructor. Use Identity.of
instead.
Parameters:
Name | Type | Description |
---|---|---|
value |
* |
Returns:
- Type
- RA.Identity
Members
(static) @@type
- Source:
Methods
fl.ap(applyWithFn) → {RA.Identity}
- Source:
- Signature:
-
ap :: Apply f => f a ~> f (a -> b) -> f b
Fantasy land Apply specification.
Example
const a = Identity.of(1);
const b = Identity.of(1).map(a => b => a + b);
a.ap(b); //=> Identity(2)
Parameters:
Name | Type | Description |
---|---|---|
applyWithFn |
RA.Identity |
Returns:
- Type
- RA.Identity
fl.chain(fn) → {RA.Identity}
- Source:
- Signature:
-
chain :: Chain m => m a ~> (a -> m b) -> m b
Fantasy land Chain specification.
Example
const a = Identity.of(1);
const fn = val => Identity.of(val + 1);
a.chain(fn).chain(fn); //=> Identity(3)
Parameters:
Name | Type | Description |
---|---|---|
fn |
function | Function returning the value of the same Chain |
Returns:
- Type
- RA.Identity
fl.concat(semigroup) → {RA.Identity}
- Source:
- Signature:
-
concat :: Semigroup a => a ~> a -> a
Fantasy land Semigroup specification.
Example
const a = Identity.of(1);
const b = Identity.of(1);
a.concat(b); //=> 2
const c = Identity.of('c');
const d = Identity.of('d');
c.concat(d); //=> 'cd'
const e = Identity.of(['e']);
const f = Identity.of(['f']);
e.concat(f); //=> ['e', 'f']
Parameters:
Name | Type | Description |
---|---|---|
semigroup |
RA.Identity |
Returns:
- Type
- RA.Identity
fl.contramap(fn) → {RA.Identity}
- Source:
- Signature:
-
contramap :: Contravariant f => f a ~> (b -> a) -> f b
Fantasy land Contravariant specification.
Example
const identity = a => a;
const add1 = a => a + 1;
const divide2 = a => a / 2;
Identity.of(divide2).contramap(add1).get()(3); //=> 2
Identity.of(identity).contramap(divide2).contramap(add1).get()(3); //=> 2
Identity.of(identity).contramap(a => divide2(add1(a))).get()(3); //=> 2
Parameters:
Name | Type | Description |
---|---|---|
fn |
function |
Returns:
- Type
- RA.Identity
fl.empty() → {RA.Identity}
- Source:
- Signature:
-
empty :: Monoid m => () -> m
Fantasy land Monoid* specification.
Partial implementation of Monoid specification. empty
method on instance only, returning
identity value of the wrapped type. Using R.empty
under the hood.
Example
const a = Identity.of('test');
const i = a.empty();
a.concat(i); //=> Identity('string');
i.concat(a); //=> Identity('string');
Returns:
- Type
- RA.Identity
fl.equals(setoid) → {boolean}
- Source:
- Signature:
-
equals :: Setoid a => a ~> a -> Boolean
Fantasy land Setoid specification.
Example
const a = Identity.of(1);
const b = Identity.of(1);
const c = Identity.of(2);
a.equals(b); //=> true
a.equals(c); //=> false
Parameters:
Name | Type | Description |
---|---|---|
setoid |
RA.Identity |
Returns:
- Type
- boolean
fl.lte(ord) → {boolean}
- Source:
- Signature:
-
lte :: Ord a => a ~> a -> Boolean
Fantasy land Ord specification.
Example
const a = Identity.of(1);
const b = Identity.of(1);
const c = Identity.of(2);
a.lte(b); //=> true
a.lte(c); //=> true
c.lte(a); //=> false
Parameters:
Name | Type | Description |
---|---|---|
ord |
RA.Identity |
Returns:
- Type
- boolean
fl.map(fn) → {RA.Identity}
- Source:
- Signature:
-
map :: Functor f => f a ~> (a -> b) -> f b
Fantasy land Functor specification.
Example
const a = Identity.of(1);
a.map(a => a + 1); //=> Identity(2)
Parameters:
Name | Type | Description |
---|---|---|
fn |
function |
Returns:
- Type
- RA.Identity
get() → {*}
- Source:
Catamorphism for a value.
Example
const a = Identity.of(1);
a.get(); //=> 1
Returns:
- Type
- *