*Main> head [1 .. 5] 1 *Main> tail [1 .. 5] [2,3,4,5] *Main> :t head head :: [a] -> a *Main> :t tail tail :: [a] -> [a] *Main> :t head [] head [] :: a *Main> head [] *** Exception: Prelude.head: empty list *Main> :t tail [] tail [] :: [a] *Main> tail [] *** Exception: Prelude.tail: empty list *Main> [1, 2, 3] ++ [4, 5] [1,2,3,4,5] *Main> :t (++) (++) :: [a] -> [a] -> [a] *Main> "hello" ++ "world" "helloworld" *Main> [] ++ [1,2] [1,2] *Main> :t length length :: Foldable t => t a -> Int *Main> length "helloworld" 10 *Main> :t zip zip :: [a] -> [b] -> [(a, b)] *Main> zip [1 .. 5] "hello" [(1,'h'),(2,'e'),(3,'l'),(4,'l'),(5,'o')] *Main> zip [1 .. 3] "hello" [(1,'h'),(2,'e'),(3,'l')] *Main> :t zip zip :: [a] -> [b] -> [(a, b)] == [a] -> ([b] -> [(a, b)]) *Main> :t zip [1 .. 3] zip [1 .. 3] :: (Num a, Enum a) => [b] -> [(a, b)] *Main> :t zip [1 .. 3] "abc" zip [1 .. 3] "abc" :: (Num a, Enum a) => [(a, Char)] *Main> :t zip [1 .. 3] :: [b] -> [(Int, b)] zip [1 .. 3] :: [b] -> [(Int, b)] :: [b] -> [(Int, b)] *Main> :t zip [True, False] zip [True, False] :: [b] -> [(Bool, b)] *Main> zip [True, False] "abc" [(True,'a'),(False,'b')] *Main> :t zip [True, False] "abc" zip [True, False] "abc" :: [(Bool, Char)] *Main> :t (++) (++) :: [a] -> [a] -> [a] *Main> :t (++) [True, False] (++) [True, False] :: [Bool] -> [Bool] *Main> (++) [True, False] [False, False] [True,False,False,False] *Main> [True, False] ++ [False, False] [True,False,False,False] *Main> :r [1 of 1] Compiling Main ( lec2.hs, interpreted ) Ok, one module loaded. *Main> :t add add :: Int -> Int -> Int *Main> add 1 2 3 *Main> :t add 1 add 1 :: Int -> Int *Main> add 1 5 6 *Main> :r [1 of 1] Compiling Main ( lec2.hs, interpreted ) Ok, one module loaded. *Main> appendLength "hello" "world" 10 *Main> :t appendLength "hello" [True, False] :1:23: error: • Couldn't match expected type ‘Char’ with actual type ‘Bool’ • In the expression: True In the second argument of ‘appendLength’, namely ‘[True, False]’ In the expression: appendLength "hello" [True, False] :1:29: error: • Couldn't match expected type ‘Char’ with actual type ‘Bool’ • In the expression: False In the second argument of ‘appendLength’, namely ‘[True, False]’ In the expression: appendLength "hello" [True, False] *Main> appendLength "hello" [True, False] :37:23: error: • Couldn't match expected type ‘Char’ with actual type ‘Bool’ • In the expression: True In the second argument of ‘appendLength’, namely ‘[True, False]’ In the expression: appendLength "hello" [True, False] :37:29: error: • Couldn't match expected type ‘Char’ with actual type ‘Bool’ • In the expression: False In the second argument of ‘appendLength’, namely ‘[True, False]’ In the expression: appendLength "hello" [True, False] *Main> :r [1 of 1] Compiling Main ( lec2.hs, interpreted ) Ok, one module loaded. *Main> factorial 4 24 *Main> :t error error :: [Char] -> a *Main> :r [1 of 1] Compiling Main ( lec2.hs, interpreted ) Ok, one module loaded. *Main> factorial -1 :42:1: error: • No instance for (Num (Int -> Int)) arising from a use of ‘-’ (maybe you haven't applied a function to enough arguments?) • In the expression: factorial - 1 In an equation for ‘it’: it = factorial - 1 *Main> factorial (-1) *** Exception: n is negative CallStack (from HasCallStack): error, called at lec2.hs:35:13 in main:Main *Main> :r [1 of 1] Compiling Main ( lec2.hs, interpreted ) Ok, one module loaded. *Main> factorial' 4 24 *Main> :r [1 of 1] Compiling Main ( lec2.hs, interpreted ) Ok, one module loaded. *Main> factorial' 4 24 *Main> factorial' (-4) *** Exception: n is negative CallStack (from HasCallStack): error, called at lec2.hs:41:16 in main:Main *Main> :r [1 of 1] Compiling Main ( lec2.hs, interpreted ) Ok, one module loaded. *Main> first (True, "abc") True *Main> :r [1 of 1] Compiling Main ( lec2.hs, interpreted ) Ok, one module loaded. *Main> second (True, "abc") "abc" *Main> :r [1 of 1] Compiling Main ( lec2.hs, interpreted ) Ok, one module loaded. *Main> length' "abc" 3 *Main> :r [1 of 1] Compiling Main ( lec2.hs, interpreted ) lec2.hs:66:19: error: Variable not in scope: x | 66 | length'' l | l == x:xs = 1 + length'' xs | ^ lec2.hs:66:21: error: Variable not in scope: xs :: [a] | 66 | length'' l | l == x:xs = 1 + length'' xs | ^^ lec2.hs:66:39: error: Variable not in scope: xs :: [a0] | 66 | length'' l | l == x:xs = 1 + length'' xs | ^^ Failed, no modules loaded. Prelude> :r [1 of 1] Compiling Main ( lec2.hs, interpreted ) Ok, one module loaded. *Main> append [1 .. 3] [4 .. 10] [1,2,3,4,5,6,7,8,9,10] *Main> append [1,2] [] [1,2]