Max
Max
is a Monoid
that will combines (2) Number
s, resulting in the largest
of the two.
- Source
- Runkit
#
ImplementsSetoid
, Semigroup
, Monoid
#
ConstructionMax
is a Monoid
fixed to the type of Number
and as such requires
a Number
instance to be passed to the constructor. A new Max
instance is
returned, wrapping the provided Number
.
The values undefined
, null
and NaN
will map to the empty
(-Infinity
)
instead of throwing a TypeError
.
- Source
- Runkit
#
Constructor Methods#
emptyempty
provides the identity for the Monoid
in that when the value it
provides is concat
ed to any other value, it will return the other value. In
the case of Max
the result of empty
is -Infinity
. empty
is available on
both the Constructor and the Instance for convenience.
- Source
- Runkit
#
Instance Methods#
equalsUsed to compare the underlying values of (2) Max
instances for equality by
value, equals
takes any given argument and returns true
if the passed
argument is a Max
with an underlying value equal to the underlying value of
the Max
the method is being called on. If the passed argument is not
a Max
or the underlying values are not equal, equals
will return false
.
- Source
- Runkit
#
concatconcat
is used to combine (2) Semigroup
s of the same type under an
operation specified by the Semigroup
. In the case of Max
, it will result
in the largest of the (2) Number
s.
- Source
- Runkit
#
valueOfvalueOf
is used on all crocks
Monoid
s as a means of extraction. While the
extraction is available, types that implement valueOf
are not necessarily
a Comonad
. This function is used primarily for convenience for some of the
helper functions that ship with crocks
. Calling valueOf
on a Max
instance
will result in the underlying Number
.
- Source
- Runkit