Applicative style understanding

118 views Asked by At

I would like to write something as the following:

(+) <$> Just 3 <*> Just 5 <*>' (+) <*> Just 6

However the problem is that I need to somehow flip <*>. What is the idiomatic way in Haskell to do the type of chaining I'm trying?

1

There are 1 answers

0
András Kovács On BEST ANSWER

<**> from Control.Applicative is flip <*>. Your example can work with that, slightly rearranged:

>((+) <$> Just 3 <*> Just 5) <**> ((+) <$> Just 6)
Just 14