Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is there no << in the Haskell standard library?

Tags:

haskell

monads

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.

like image 696
Benjamin Hodgson Avatar asked Jan 05 '13 21:01

Benjamin Hodgson


1 Answers

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.

like image 133
Philip JF Avatar answered Sep 28 '22 21:09

Philip JF