Applicative
public protocol Applicative : Functor
An Applicative Functor is a Functor that also provides functionality to lift pure expressions, and sequence computations and combine their results.
Instances of this typeclass must obey the following laws:
Identity
ap(pure(id), v) == vComposition
ap(ap(ap(pure(compose), u), v), w) == compose(u, compose(v, w))Homomorphism
ap(pure(f), pure(x)) == pure(f(x))Interchange
ap(fa, pure(b)) == ap(pure({ x in x(a) }), fa)
-
Lifts a value to the context type implementing this instance of
Applicative.Declaration
Swift
static func pure<A>(_ a: A) -> Kind<Self, A>Parameters
aValue to be lifted.
Return Value
Provided value in the context type implementing this instance.
-
Sequential application.
Declaration
Parameters
ffA function in the context implementing this instance.
faA value in the context implementing this instance.
Return Value
A value in the context implementing this instance, resulting of the transformation of the contained original value with the contained function.
-
zipRight(_:_:)Extension methodSequentially compose two computations, discarding the value produced by the first.
Declaration
Parameters
fa1st computation.
fb2nd computation.
Return Value
Result of running the second computation after the first one.
-
zipLeft(_:_:)Extension methodSequentially compose two computations, discarding the value produced by the second.
Declaration
Parameters
fa1st computation.
fb2nd computation.
Return Value
Result produced from the first computation after both are computed.
-
product(_:_:)Extension methodCreates a tuple in the context implementing this instance from two values in the same context.
Declaration
Parameters
fa1st value for the tuple.
fb2nd value for the tuple.
Return Value
A tuple of the provided values in the context implementing this instance.
-
product(_:_:)Extension methodAdds an element to the right of a tuple in the context implementing this instance.
Declaration
Parameters
faA tuple of two elements in the context implementing this instance.
fzA value in the context implementing this instance.
Return Value
A tuple with the value of the second argument added to the right of the tuple, in the context implementing this instance.
-
product(_:_:)Extension methodAdds an element to the right of a tuple in the context implementing this instance.
Declaration
Parameters
faA tuple of three elements in the context implementing this instance.
fzA value in the context implementing this instance.
Return Value
A tuple with the value of the second argument added to the right of the tuple, in the context implementing this instance.
-
product(_:_:)Extension methodAdds an element to the right of a tuple in the context implementing this instance.
Declaration
Parameters
faA tuple of four elements in the context implementing this instance.
fzA value in the context implementing this instance.
Return Value
A tuple with the value of the second argument added to the right of the tuple, in the context implementing this instance.
-
product(_:_:)Extension methodAdds an element to the right of a tuple in the context implementing this instance.
Declaration
Parameters
faA tuple of five elements in the context implementing this instance.
fzA value in the context implementing this instance.
Return Value
A tuple with the value of the second argument added to the right of the tuple, in the context implementing this instance.
-
product(_:_:)Extension methodAdds an element to the right of a tuple in the context implementing this instance.
Declaration
Parameters
faA tuple of six elements in the context implementing this instance.
fzA value in the context implementing this instance.
Return Value
A tuple with the value of the second argument added to the right of the tuple, in the context implementing this instance.
-
product(_:_:)Extension methodAdds an element to the right of a tuple in the context implementing this instance.
Declaration
Parameters
faA tuple of seven elements in the context implementing this instance.
fzA value in the context implementing this instance.
Return Value
A tuple with the value of the second argument added to the right of the tuple, in the context implementing this instance.
-
product(_:_:)Extension methodAdds an element to the right of a tuple in the context implementing this instance.
Declaration
Parameters
faA tuple of eight elements in the context implementing this instance.
fzA value in the context implementing this instance.
Return Value
A tuple with the value of the second argument added to the right of the tuple, in the context implementing this instance.
-
map2Eval(_:_:_:)Extension methodPerforms two computations in the context implementing this instance and combines their result using the provided function.
Declaration
Parameters
faA value in the context implementing this instance.
fbA lazy value in the context implementing this instance.
fA function to combine the result of the computations.
Return Value
A lazy value with the result of combining the results of each computation.
-
zip(_:_:)Extension methodCreates a tuple out of two values in the context implementing this instance.
Declaration
Parameters
a1st value of the tuple.
b2nd value of the tuple.
Return Value
A tuple in the context implementing this instance.
-
zip(_:_:_:)Extension methodCreates a tuple out of three values in the context implementing this instance.
Declaration
Parameters
a1st value of the tuple.
b2nd value of the tuple.
c3rd value of the tuple.
Return Value
A tuple in the context implementing this instance.
-
zip(_:_:_:_:)Extension methodCreates a tuple out of four values in the context implementing this instance.
Declaration
Parameters
a1st value of the tuple.
b2nd value of the tuple.
c3rd value of the tuple.
d4th value of the tuple.
Return Value
A tuple in the context implementing this instance.
-
zip(_:_:_:_:_:)Extension methodCreates a tuple out of five values in the context implementing this instance.
Declaration
Parameters
a1st value of the tuple.
b2nd value of the tuple.
c3rd value of the tuple.
d4th value of the tuple.
e5th value of the tuple.
Return Value
A tuple in the context implementing this instance.
-
zip(_:_:_:_:_:_:)Extension methodCreates a tuple out of six values in the context implementing this instance.
Declaration
Parameters
a1st value of the tuple.
b2nd value of the tuple.
c3rd value of the tuple.
d4th value of the tuple.
e5th value of the tuple.
g6th value of the tuple.
Return Value
A tuple in the context implementing this instance.
-
zip(_:_:_:_:_:_:_:)Extension methodCreates a tuple out of seven values in the context implementing this instance.
Declaration
Parameters
a1st value of the tuple.
b2nd value of the tuple.
c3rd value of the tuple.
d4th value of the tuple.
e5th value of the tuple.
g6th value of the tuple.
h7th value of the tuple.
Return Value
A tuple in the context implementing this instance.
-
zip(_:_:_:_:_:_:_:_:)Extension methodCreates a tuple out of eight values in the context implementing this instance.
Declaration
Parameters
a1st value of the tuple.
b2nd value of the tuple.
c3rd value of the tuple.
d4th value of the tuple.
e5th value of the tuple.
g6th value of the tuple.
h7th value of the tuple.
i8th value of the tuple.
Return Value
A tuple in the context implementing this instance.
-
zip(_:_:_:_:_:_:_:_:_:)Extension methodCreates a tuple out of nine values in the context implementing this instance.
Declaration
Parameters
a1st value of the tuple.
b2nd value of the tuple.
c3rd value of the tuple.
d4th value of the tuple.
e5th value of the tuple.
g6th value of the tuple.
h7th value of the tuple.
i8th value of the tuple.
j9th value of the tuple.
Return Value
A tuple in the context implementing this instance.
-
map(_:_:_:)Extension methodCombines the result of two computations in the context implementing this instance, using the provided function.
Declaration
Parameters
a1st computation.
b2nd computation.
fCombination function.
Return Value
Result of combining the provided computations, in the context implementing this instance.
-
map(_:_:_:_:)Extension methodCombines the result of three computations in the context implementing this instance, using the provided function.
Declaration
Parameters
a1st computation.
b2nd computation.
c3rd computation.
fCombination function.
Return Value
Result of combining the provided computations, in the context implementing this instance.
-
map(_:_:_:_:_:)Extension methodCombines the result of four computations in the context implementing this instance, using the provided function.
Declaration
Parameters
a1st computation.
b2nd computation.
c3rd computation.
d4th computation.
fCombination function.
Return Value
Result of combining the provided computations, in the context implementing this instance.
-
map(_:_:_:_:_:_:)Extension methodCombines the result of five computations in the context implementing this instance, using the provided function.
Declaration
Parameters
a1st computation.
b2nd computation.
c3rd computation.
d4th computation.
e5th computation.
fCombination function.
Return Value
Result of combining the provided computations, in the context implementing this instance.
-
map(_:_:_:_:_:_:_:)Extension methodCombines the result of six computations in the context implementing this instance, using the provided function.
Declaration
Parameters
a1st computation.
b2nd computation.
c3rd computation.
d4th computation.
e5th computation.
g6th computation.
fCombination function.
Return Value
Result of combining the provided computations, in the context implementing this instance.
-
map(_:_:_:_:_:_:_:_:)Extension methodCombines the result of seven computations in the context implementing this instance, using the provided function.
Declaration
Parameters
a1st computation.
b2nd computation.
c3rd computation.
d4th computation.
e5th computation.
g6th computation.
h7th computation.
fCombination function.
Return Value
Result of combining the provided computations, in the context implementing this instance.
-
map(_:_:_:_:_:_:_:_:_:)Extension methodCombines the result of eight computations in the context implementing this instance, using the provided function.
Declaration
Parameters
a1st computation.
b2nd computation.
c3rd computation.
d4th computation.
e5th computation.
g6th computation.
h7th computation.
i8th computation.
fCombination function.
Return Value
Result of combining the provided computations, in the context implementing this instance.
-
map(_:_:_:_:_:_:_:_:_:_:)Extension methodCombines the result of nine computations in the context implementing this instance, using the provided function.
Declaration
Parameters
a1st computation.
b2nd computation.
c3rd computation.
d4th computation.
e5th computation.
g6th computation.
h7th computation.
i8th computation.
j9th computation.
fCombination function.
Return Value
Result of combining the provided computations, in the context implementing this instance.
Install in Dash
Applicative Protocol Reference