$ ls lec1.hs lec1Prep.hs $ ghci lec1.hs GHCi, version 8.8.4: https://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( lec1.hs, interpreted ) Ok, one module loaded. *Main> main Hello World! *Main> :r Ok, one module loaded. *Main> :r Ok, one module loaded. *Main> :q Leaving GHCi. $ ghc lec1.hs [1 of 1] Compiling Main ( lec1.hs, lec1.o ) Linking lec1 ... $ ls lec1 lec1.hi lec1.hs lec1.o lec1Prep.hs $ ./lec1 Hello World! $ ghci lec1.hs GHCi, version 8.8.4: https://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( lec1.hs, interpreted ) Ok, one module loaded. *Main> :r [1 of 1] Compiling Main ( lec1.hs, interpreted ) lec1.hs:7:8: error: Unexpected do block in function application: do putStrLn "Hello World!" You could write it with parentheses Or perhaps you meant to enable BlockArguments? | 7 | main = do | ^^... Failed, no modules loaded. Prelude> :r [1 of 1] Compiling Main ( lec1.hs, interpreted ) Ok, one module loaded. *Main> main Hello World! Hello World twice! *Main> list1 [1,2,3] *Main> :t list1 list1 :: [Int] *Main> :r [1 of 1] Compiling Main ( lec1.hs, interpreted ) Ok, one module loaded. *Main> :t list1 list1 :: [Integer] *Main> :r [1 of 1] Compiling Main ( lec1.hs, interpreted ) Ok, one module loaded. *Main> list2 "abc" *Main> :t list2 list2 :: [Char] *Main> :r [1 of 1] Compiling Main ( lec1.hs, interpreted ) Ok, one module loaded. *Main> :t list2 list2 :: [Char] *Main> :r [1 of 1] Compiling Main ( lec1.hs, interpreted ) Ok, one module loaded. *Main> :t list2 list2 :: String *Main> :r [1 of 1] Compiling Main ( lec1.hs, interpreted ) Ok, one module loaded. *Main> :t emptyList emptyList :: [a] *Main> :t head head :: [a] -> a *Main> head [1,2,3] 1 *Main> head "adadada" 'a' *Main> head ["abc", "efg", "xyz"] "abc" *Main> :t ["abc", "efg", "xyz"] ["abc", "efg", "xyz"] :: [[Char]] *Main> head [] *** Exception: Prelude.head: empty list *Main> :r [1 of 1] Compiling Main ( lec1.hs, interpreted ) lec1.hs:22:1: error: Illegal type signature: ‘String list2’ Type signatures are only allowed in patterns with ScopedTypeVariables | 22 | list2 :: String | ^^^^^^^^^^^^^^^^... Failed, no modules loaded. Prelude> :r [1 of 1] Compiling Main ( lec1.hs, interpreted ) lec1.hs:23:10: error: • Couldn't match expected type ‘Int’ with actual type ‘Char’ • In the expression: 'a' In the expression: ['a', 'b', 'c'] In an equation for ‘list2’: list2 = ['a', 'b', 'c'] | 23 | list2 = ['a', 'b', 'c'] | ^^^ lec1.hs:23:15: error: • Couldn't match expected type ‘Int’ with actual type ‘Char’ • In the expression: 'b' In the expression: ['a', 'b', 'c'] In an equation for ‘list2’: list2 = ['a', 'b', 'c'] | 23 | list2 = ['a', 'b', 'c'] | ^^^ lec1.hs:23:20: error: • Couldn't match expected type ‘Int’ with actual type ‘Char’ • In the expression: 'c' In the expression: ['a', 'b', 'c'] In an equation for ‘list2’: list2 = ['a', 'b', 'c'] | 23 | list2 = ['a', 'b', 'c'] | ^^^ Failed, no modules loaded. Prelude> :r [1 of 1] Compiling Main ( lec1.hs, interpreted ) Ok, one module loaded. *Main> head [] *** Exception: Prelude.head: empty list *Main> :t tail tail :: [a] -> [a] *Main> tail [1,2,3] [2,3] *Main> tail [] *** Exception: Prelude.tail: empty list *Main> :t (:) (:) :: a -> [a] -> [a] *Main> 1:[] [1] *Main> 1:(2:(3:[])) [1,2,3] *Main> :t (!!) (!!) :: [a] -> Int -> a *Main> (1:(2:(3:[]))) !! 0 1 *Main> (1:(2:(3:[]))) !! 1 2 *Main> "abcd" !! 0 'a' *Main> [] !! 1 *** Exception: Prelude.!!: index too large *Main> :t take take :: Int -> [a] -> [a] *Main> take 3 "abcdefg" "abc" *Main> take 3 "" "" *Main> take 3 "ab" "ab" *Main> length [] 0 *Main> length "ab" 2 *Main> drop 2 "abcd" "cd" *Main> drop 5 "abcd" "" *Main> drop 0 "abcd" "abcd" *Main> :t drop drop :: Int -> [a] -> [a] *Main> :t (++) (++) :: [a] -> [a] -> [a] *Main> "abc" ++ "efg" "abcefg" *Main> "abc" ++ [1,2,3] :50:11: error: • No instance for (Num Char) arising from the literal ‘1’ • In the expression: 1 In the second argument of ‘(++)’, namely ‘[1, 2, 3]’ In the expression: "abc" ++ [1, 2, 3] *Main> head [] *** Exception: Prelude.head: empty list *Main> :r [1 of 1] Compiling Main ( lec1.hs, interpreted ) Ok, one module loaded. *Main> tuple3 ([1,2,3],'a') *Main> :r [1 of 1] Compiling Main ( lec1.hs, interpreted ) Ok, one module loaded. *Main> :t lookup lookup :: Eq a => a -> [(a, b)] -> Maybe b *Main> :t lookup lookup :: Eq a => a -> [(a, b)] -> Maybe b *Main> :t (==) (==) :: Eq a => a -> a -> Bool *Main> lookup 1 example1 :58:10: error: • Variable not in scope: example1 :: [(Integer, b)] • Perhaps you meant ‘exampe1’ (line 44) *Main> :r [1 of 1] Compiling Main ( lec1.hs, interpreted ) Ok, one module loaded. *Main> lookup 1 example1 Just "Alice" *Main> :r [1 of 1] Compiling Main ( lec1.hs, interpreted ) Ok, one module loaded. *Main> lookup 1 example1 Just "Alice" *Main> lookup 4 example1 Nothing *Main> :t fst fst :: (a, b) -> a *Main> :t snd snd :: (a, b) -> b *Main> fst (1, 'b') 1 *Main> snd (1, '') :67:9: error: Parser error on `''` Character literals may not be empty *Main> snd (1, 'b') 'b' *Main> fst (1, 2, 'c') :69:5: error: • Couldn't match expected type ‘(a, b0)’ with actual type ‘(Integer, Integer, Char)’ • In the first argument of ‘fst’, namely ‘(1, 2, 'c')’ In the expression: fst (1, 2, 'c') In an equation for ‘it’: it = fst (1, 2, 'c') • Relevant bindings include it :: a (bound at :69:1)