The ap
method is a method that Functor
does not have:
The ap
method is a method that Functor
does not have:
Apply
also offers variants of ap
.
Apply
also offers variants of ap
. The functions apN
(for N
between 2
and 22
)
accept N
arguments where ap
accepts 1
.
Note that if any of the arguments of this example is None
, the
final result is None
as well. The effects of the context we are operating on
are carried through the entire computation:
The |@|
operator offers an alternative syntax for the higher-arity Apply
functions (apN
, mapN
and tupleN
).
The |@|
operator offers an alternative syntax for the higher-arity Apply
functions (apN
, mapN
and tupleN
).
In order to use it, first import cats.syntax.all._
or cats.syntax.apply._
.
All instances created by |@|
have map
, ap
, and tupled
methods of the appropriate arity:
And like functors, Apply
instances also compose:
And like functors, Apply
instances also compose:
Since Apply
extends Functor
, we can use the map
method from Functor
:
Since Apply
extends Functor
, we can use the map
method from Functor
:
Similarly, mapN
functions are available:
Similarly, mapN
functions are available:
Similarly, tupleN
functions are available:
Similarly, tupleN
functions are available:
This method has been deprecated in favor of macro assertion and will be removed in a future version of ScalaTest. If you need this, please copy the source code into your own trait instead.
This method has been deprecated in favor of macro assertion and will be removed in a future version of ScalaTest. If you need this, please copy the source code into your own trait instead.
This method has been deprecated in favor of macro assumption and will be removed in a future version of ScalaTest. If you need this, please copy the source code into your own trait instead.
This method has been deprecated in favor of macro assumption and will be removed in a future version of ScalaTest. If you need this, please copy the source code into your own trait instead.
Please use 'an [Exception] should be thrownBy { ... }' syntax instead
This expect method has been deprecated. Please replace all invocations of expect with an identical invocation of assertResult instead.
This expect method has been deprecated. Please replace all invocations of expect with an identical invocation of assertResult instead.
This expectResult method has been deprecated. Please replace all invocations of expectResult with an identical invocation of assertResult instead.
This expectResult method has been deprecated. Please replace all invocations of expectResult with an identical invocation of assertResult instead.
Apply
extends theFunctor
type class (which features the familiarmap
function) with a new functionap
. Theap
function is similar tomap
in that we are transforming a value in a context (a context being theF
inF[A]
; a context can beOption
,List
orFuture
for example). However, the difference betweenap
andmap
is that forap
the function that takes care of the transformation is of typeF[A => B]
, whereas formap
it isA => B
:Here are the implementations of
Apply
for theOption
andList
types: