The Applicative must follow these laws:
- Identity Law: An application of identity should not change the data:
pure id <*> v == v
- Homomorphism: An application of a function to a data (f x) is equivalent to the application of Applicative of the function applied to pure data (data inducted in Applicative):
pure f <*> pure x == pure (f x)
- Interchange: This is equivalent to saying that
f (a -> b) -> f a == f b, which should be equivalent to f ((a -> b) -> b) -> f (a -> b) == f b:
u <*> pure y = pure ($ y) <*> u
- Composition: Stipulates that an Applicative compose operator is similar to the function composition (.):
pure (.) <*> u <*> v <*> w = u <*> (v <*> w)
Here, the application of the composition pure (.) <*> u ...