Binding operator (= <<) with two parameters

Could not find a better topic title, unfortunately ... sorry.

I have a function that takes two pure parameters and returns a monadic value. And I have two monadic values โ€‹โ€‹that need to be submitted to it. This is probably something stupid that I miss. I would usually use (= <<) if it was only one parameter, but now I'm stuck with two.

So I need a function with this type of signature

(a1 -> a2  -> m b) -> m a1 -> m a2 -> m b

Hoogle gives me nothing. I know that I can just use the โ€œmakeโ€ notation, but I was wondering if it could be done without it? Is curry with the bind operator possible something like this:

(function =<< value1) =<< value2

, "liftM2" , , .

.

+4
2

join :: Monad m => m (m a) -> m a liftM2:

join $ liftM2 function value1 value2
+7

, .

bind2 f m n = do
     m' <- m
     n' <- n
     f m' n'
+1

Source: https://habr.com/ru/post/1531274/


All Articles