Haskell’s function type
((->) r) is an Applicative functor. Similar to the previous two posts in this series, in this post I will verify that the applicative laws hold for the
((->) r) type.
Haskell’s list type
 is an Applicative functor. Similar to the previous post, this post will verify that the applicative laws hold for the
Applicative functors come with a set of laws that apply for all Applicative instances. These laws are as follows:
pure id <*> v = v
pure f <*> pure x = pure (f x)
u <*> pure y = pure ($y) <*> u
pure (.) <*> u <*> v <*> w = u <*> (v <*> w)
Maybe type is made an instance of the
Applicative type class as follows:
instance Applicative Maybe where pure = Just Nothing <*> _ = Nothing (Just f) <*> something = fmap f something
When working with lists in Haskell, occasionally there’s a need to perform index based operations, such as adding an element at a particular index. As a Haskell newbie, using
foldr is not the first idea that comes to mind when indices are involved. However, there is a general pattern that can be applied when using folds for index-based list operations.
Patrick McKenzie wrote an excellent post about compensation and salary transparency. The entire post is really informative, but for me, this passage is a true gem. Every word here is absolutely true:Read more…