[1,2,3].map(x => x + 1)
[1,2,3].map(x => x + 1)
[1,2,3].flatMap(x => [x + 1])
[1,2,3].flatMap(x => [x + 1])
[1,2,3].map(a => a + 1).filter(b => b != 3)
[1,2,3].map(a => a + 1).filter(b => b != 3)
[1,2,3].flatMap(a => [a + 1]).flatMap(b => b != 3 ? [b] : [])
[1,2,3].flatMap(a => [a + 1]).flatMap(b => b != 3 ? [b] : [])
[1,2,3].flatMap(a => [a + 1].flatMap(b => b != 3 ? [b] : []))
[1,2,3].flatMap(a => [a + 1].flatMap(b => b != 3 ? [b] : []))
[1,2,3] >>= \a -> [a+1] >>= \b -> if b == 3 then [] else [b]
[1,2,3] >>= \a -> [a+1] >>= \b -> if b == 3 then [] else [b]
do
a <- [1,2,3]
b <- [a+1]
if b == 3 then [] else [b]
do
a <- [1,2,3]
b <- [a+1]
if b == 3 then [] else [b]
streetName = getStreetName (getAddress (getUser 17))
streetName = getStreetName (getAddress (getUser 17))
case getUser 17 of
Nothing -> Nothing
Just user ->
case getAddress user of
Nothing -> Nothing
Just address ->
getStreetName address
case getUser 17 of
Nothing -> Nothing
Just user ->
case getAddress user of
Nothing -> Nothing
Just address ->
getStreetName address
do
user <- getUser 17
addr <- getAddress user
getStreetName addr
do
user <- getUser 17
addr <- getAddress user
getStreetName addr
add2 :: State Integer Integer
add2 = do
-- add 1 to state
x <- get
put (x + 1)
-- increment in another way
modify (+1)
-- return state
get
evalState add2 7
=> 9
add2 :: State Integer Integer
add2 = do
-- add 1 to state
x <- get
put (x + 1)
-- increment in another way
modify (+1)
-- return state
get
evalState add2 7
=> 9
main :: IO ()
main = do
putStrLn "Hello World"
main :: IO ()
main = do
putStrLn "Hello World"
main = do
putStrLn "What is your name?"
name <- getLine
putStrLn ("hello" ++ name)
main = do
putStrLn "What is your name?"
name <- getLine
putStrLn ("hello" ++ name)
[1,2,3].map(x => x + 1)
[1,2,3].flatMap(x => [x + 1])
[1,2,3].map(a => a + 1).filter(b => b != 3)
[1,2,3].flatMap(a => [a + 1]).flatMap(b => b != 3 ? [b] : [])
[1,2,3].flatMap(a => [a + 1].flatMap(b => b != 3 ? [b] : []))
[1,2,3] >>= \a -> [a+1] >>= \b -> if b == 3 then [] else [b]
do
a <- [1,2,3]
b <- [a+1]
if b == 3 then [] else [b]
streetName = getStreetName (getAddress (getUser 17))
case getUser 17 of
Nothing -> Nothing
Just user ->
case getAddress user of
Nothing -> Nothing
Just address ->
getStreetName address
do
user <- getUser 17
addr <- getAddress user
getStreetName addr
add2 :: State Integer Integer
add2 = do
-- add 1 to state
x <- get
put (x + 1)
-- increment in another way
modify (+1)
-- return state
get
evalState add2 7
=> 9
main :: IO ()
main = do
putStrLn "Hello World"
main = do
putStrLn "What is your name?"
name <- getLine
putStrLn ("hello" ++ name)
[1,2,3].map(x => x + 1)
[1,2,3].flatMap(x => [x + 1])
[1,2,3].map(a => a + 1).filter(b => b != 3)
[1,2,3].flatMap(a => [a + 1]).flatMap(b => b != 3 ? [b] : [])
[1,2,3].flatMap(a => [a + 1].flatMap(b => b != 3 ? [b] : []))
[1,2,3] >>= \a -> [a+1] >>= \b -> if b == 3 then [] else [b]
do
a <- [1,2,3]
b <- [a+1]
if b == 3 then [] else [b]
streetName = getStreetName (getAddress (getUser 17))
case getUser 17 of
Nothing -> Nothing
Just user ->
case getAddress user of
Nothing -> Nothing
Just address ->
getStreetName address
do
user <- getUser 17
addr <- getAddress user
getStreetName addr
add2 :: State Integer Integer
add2 = do
-- add 1 to state
x <- get
put (x + 1)
-- increment in another way
modify (+1)
-- return state
get
evalState add2 7
=> 9
main :: IO ()
main = do
putStrLn "Hello World"
main = do
putStrLn "What is your name?"
name <- getLine
putStrLn ("hello" ++ name)
Like any other practical language, Haskell has a bunch of built-in functions which interface with the outside world: putStrLineputStrLn, readLinegetLine and so on. These functions are called "impure" because they either cause side effects or have non-deterministic results. Even something simple like getting the time is considered impure because the result is non-deterministic – calling it twice with the same arguments may return different values.
Like any other practical language, Haskell has a bunch of built-in functions which interface with the outside world: putStrLine, readLine and so on. These functions are called "impure" because they either cause side effects or have non-deterministic results. Even something simple like getting the time is considered impure because the result is non-deterministic – calling it twice with the same arguments may return different values.
Like any other practical language, Haskell has a bunch of built-in functions which interface with the outside world: putStrLn, getLine and so on. These functions are called "impure" because they either cause side effects or have non-deterministic results. Even something simple like getting the time is considered impure because the result is non-deterministic – calling it twice with the same arguments may return different values.
do a <- [1,2,3]
b <- [a+1]
if b == 3 then [] else [b]
main = do
putStrLn "What is your name?"
name <- getLine
putStrLn ("hello" ++ name)
do a <- [1,2,3]
b <- [a+1]
if b == 3 then [] else [b]
main = do
putStrLn "What is your name?"
name <- getLine
putStrLn "hello" ++ name
do a <- [1,2,3]
b <- [a+1]
if b == 3 then [] else [b]
main = do
putStrLn "What is your name?"
name <- getLine
putStrLn ("hello" ++ name)
- 316
- 5
- 16
- 49k
- 7
- 56
- 118
- 31.3k
- 22
- 110
- 134
- 14.4k
- 8
- 42
- 81
- 746
- 4
- 12