1

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?

user3139545
  • 6,882
  • 13
  • 44
  • 87
  • 1
    Are you trying to sum a list of `Num a => Maybe a` values? If so, then `fmap sum . sequence` should do it. –  Jun 14 '15 at 20:39

1 Answers1

4

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

>((+) <$> Just 3 <*> Just 5) <**> ((+) <$> Just 6)
Just 14
András Kovács
  • 29,931
  • 3
  • 53
  • 99