September 2018
Intermediate to advanced
398 pages
9h 43m
English
As with other Cats type classes, an Apply instance must obey certain laws.
Given a type F that has an Apply[F] instance, for all types A, given an instance fa: F[A], the following equalities must be verified:
(fa product (fb product fc)) == ((fa product fb) product fc).map { case ((a, b), c) => (a, (b,c)) }
We can change the parenthesis and hence the evaluation order without changing the result.
(fbc <*> (fab <*> fa)) == ((fbc.map(_.compose[A] _) <*> fab) <*> fa)
This is similar to the function composition law that we saw in the ...
Read now
Unlock full access