Applicative is Apply that also has point or pure methods. Scalaz defines Applicative[F[_]] trait with point abstract method.
point method lifts A to F[A]. Since Applicative is Apply it inherits all the methods that Apply offers plus it needs to provide implementation for map and ap methods. Note that Applicative implements map using point and ap methods:
Scalaz offers following syntax/derived functions:
- η, point and pure. Lift value into F.
- replicateM. Performs action n times and returns list of results.
- replicateM_. Performs action n times and returns unit.
Since Option is Applicative I’m gonna demonstrate those methods on Optioni with short examples:
Output
1.η Some(1)
1.point Some(1)
1.pure Some(1)
1.some.replicateM(3) Some(List(1, 1, 1))
1.some.replicateM_(3) Some(())