Could not come up with a better subject title, unfortunately ... sorry.
I have a function that takes two pure parameters and returns a monadic value. And I have two monadic values to be fed into it. This is probably something stupid that I am missing. I would normally use (=<<) if it was just one parameter but now I am stuck with two.
So I need a function with this type of signature
(a1 -> a2 -> m b) -> m a1 -> m a2 -> m b
Hoogle does not give me anything. I know I can just use 'do' notation but I was wondering if this can be done without? Is it possible to curry with the bind operator something like this:
(function =<< value1) =<< value2
I thought 'liftM2' could be of use but it takes a function that returns a pure value.
Thank you.
One possible solution is to use join :: Monad m => m (m a) -> m a
in conjunction with liftM2
:
join $ liftM2 function value1 value2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With