# → Do You Need Self Discipline To Have Fun?

I can relate to this excellent post by Scott Young, where he makes the case that ease of doing an activity and its enjoyment aren’t the same.

# Applicative Laws for `((->) r)` Type

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.

# Applicative Laws for `[]` 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 `[]` type.

# Applicative Laws for `Maybe` Type

Applicative functors come with a set of laws that apply for all Applicative instances. These laws are as follows:

• Identity: `pure id <*> v = v`

• Homomorphism: `pure f <*> pure x = pure (f x)`

• Interchange: `u <*> pure y = pure (\$y) <*> u`

• Composition: `pure (.) <*> u <*> v <*> w = u <*> (v <*> w)`

# Maybe as an Applicative Functor

`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``````

# Pascal’s Triangle

One of the exercises in Structure and Implementation of Computer Programs deals with generating elements of the Pascal’s Triangle.

# Index Based List Operations Using folds in Haskell

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 `foldl` or `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: