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).
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.
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.
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.
The ++ operator is the list concatenation operator which takes two lists as operands and "combine" them into a single list.
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
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