Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the >> symbol mean in Haskell

Tags:

syntax

haskell

I was reading the Guestbook example for Happstack and noticed the >> symbol which I didn't see before in the textbooks I studied to learn Haskell (for instance see line 23). What is it?

I could not find it in Google because it ignores the >> totally (Bing does not but comes up with tons of non-related results).

like image 941
CharlesS Avatar asked Feb 27 '10 09:02

CharlesS


People also ask

What does AT symbol mean in Haskell?

The @ Symbol is used to both give a name to a parameter and match that parameter against a pattern that follows the @ . It's not specific to lists and can also be used with other data structures.

What is && in Haskell?

Haskell provides three basic functions for further manipulation of truth values as in logic propositions: (&&) performs the and operation. Given two boolean values, it evaluates to True if both the first and the second are True , and to False otherwise.

What does <$> mean in Haskell?

It's merely an infix synonym for fmap , so you can write e.g. Prelude> (*2) <$> [1.. 3] [2,4,6] Prelude> show <$> Just 11 Just "11" Like most infix functions, it is not built-in syntax, just a function definition. But functors are such a fundamental tool that <$> is found pretty much everywhere.

What does ++ do Haskell?

The ++ operator is the list concatenation operator which takes two lists as operands and "combine" them into a single list.


1 Answers

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 
like image 104
kennytm Avatar answered Sep 18 '22 22:09

kennytm