The Monad
class defines a >>
method, which sequences two monadic actions:
>> :: Monad m => m a -> m b -> m b
The binding operator >>=
has a flipped-argument equivalent, =<<
; as do the monadic function composition ('fish') operators >=>
and <=<
. There doesn't seem to be a <<
, though (after a few minutes of Hoogling). Why is this?
Edit: I know it's not a big deal. I just like the way certain lines of code look with the left-pointing operators. x <- doSomething =<< doSomethingElse
just looks nicer, with the arrows all going the same way, than x <- doSomethingElse >>= doSomething
.
To the best of my knowledge there is no good reason. Note, that your Monad
should also be an instance of Applicative
, so you can use <*
and *>
instead as your sequencing tools.
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