What does the >> symbol mean in Haskell

At the ghci command prompt, you can type:

:info >>

And get a result like:

class Monad m where
...
(>>) :: m a -> m b -> m b
...
        -- Defined in GHC.Base
infixl 1 >>

From there, you can just take a look at the source code to learn more.

And just for the sake of answering your question:

k >> f = k >>= \_ -> f

In do-notation

a >> b >> c >> d

is equivalent to

do a
   b
   c
   d

(and similarly a >>= (b >>= (c >>= d)) is equivalent to

do r1 <- a
   r2 <- b r1
   r3 <- c r2
   d r3

Hayoo recognises this kind of operator: http://holumbus.fh-wedel.de/hayoo/hayoo.html

(>>) is like (>>=), in that it sequences two actions, except that it ignores the result from the first one.

Tags:

Syntax

Haskell