GHCi, version 8.8.4: https://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( lec2.hs, interpreted ) lec2.hs:32:1: warning: [-Wincomplete-patterns] Pattern match(es) are non-exhaustive In an equation for ‘listHead’: Patterns not matched: [] | 32 | listHead (x:xs) = x | ^^^^^^^^^^^^^^^^^^^ lec2.hs:35:1: warning: [-Wincomplete-patterns] Pattern match(es) are non-exhaustive In an equation for ‘listTail’: Patterns not matched: [] | 35 | listTail (x:xs) = xs | ^^^^^^^^^^^^^^^^^^^^ lec2.hs:66:1: warning: [-Wincomplete-patterns] Pattern match(es) are non-exhaustive In an equation for ‘zip'’: Patterns not matched: [] (_:_) (_:_) [] | 66 | zip' [] [] = [] | ^^^^^^^^^^^^^^^... Ok, one module loaded. *Main> :r [1 of 1] Compiling Main ( lec2.hs, interpreted ) lec2.hs:32:1: warning: [-Wincomplete-patterns] Pattern match(es) are non-exhaustive In an equation for ‘listHead’: Patterns not matched: [] | 32 | listHead (x:xs) = x | ^^^^^^^^^^^^^^^^^^^ lec2.hs:35:1: warning: [-Wincomplete-patterns] Pattern match(es) are non-exhaustive In an equation for ‘listTail’: Patterns not matched: [] | 35 | listTail (x:xs) = xs | ^^^^^^^^^^^^^^^^^^^^ Ok, one module loaded. *Main> :t error error :: [Char] -> a *Main> :r [1 of 1] Compiling Main ( lec2.hs, interpreted ) lec2.hs:36:1: warning: [-Wincomplete-patterns] Pattern match(es) are non-exhaustive In an equation for ‘listTail’: Patterns not matched: [] | 36 | listTail (x:xs) = xs | ^^^^^^^^^^^^^^^^^^^^ Ok, one module loaded. *Main> listHead [] *** Exception: no element in emptylist CallStack (from HasCallStack): error, called at lec2.hs:33:15 in main:Main *Main> :q Leaving GHCi. $ cd .. $ cd lec3/ $ ls lec3.hs lec3.hs~ lec3Prep.hs $ ghci lec3.hs GHCi, version 8.8.4: https://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( lec3.hs, interpreted ) Ok, one module loaded. *Main> mapMap (\ x -> x + 2) [0 .. 10] :1:1: error: • Variable not in scope: mapMap :: (Integer -> Integer) -> [Integer] -> t • Perhaps you meant one of these: ‘mapM’ (imported from Prelude), ‘mapM_’ (imported from Prelude), ‘myMap’ (line 12) *Main> myMap (\ x -> x + 2) [0 .. 10] [2,3,4,5,6,7,8,9,10,11,12] *Main> myMap (\ x -> x:",") "abcde" ["a,","b,","c,","d,","e,"] *Main> :t concat concat :: Foldable t => t [a] -> [a] *Main> concat (myMap (\ x -> x:",") "abcde") "a,b,c,d,e," *Main> :r [1 of 1] Compiling Main ( lec3.hs, interpreted ) Ok, one module loaded. *Main> myFilter (\ x -> mod x 2 == 0) [0 .. 20] [0,2,4,6,8,10,12,14,16,18,20] *Main> :r [1 of 1] Compiling Main ( lec3.hs, interpreted ) Ok, one module loaded. *Main> :r [1 of 1] Compiling Main ( lec3.hs, interpreted ) Ok, one module loaded. *Main> :r [1 of 1] Compiling Main ( lec3.hs, interpreted ) Ok, one module loaded. *Main> myFilter' (\ x -> mod x 2 == 0) [0 .. 20] [] *Main> :r [1 of 1] Compiling Main ( lec3.hs, interpreted ) Ok, one module loaded. *Main> :r [1 of 1] Compiling Main ( lec3.hs, interpreted ) lec3.hs:33:1: warning: [-Woverlapping-patterns] Pattern match is redundant In an equation for ‘f’: f x = ... | 33 | f x = x + 2 | ^^^^^^^^^^^ Ok, one module loaded. *Main> f 2 3 *Main> f 2 3 *Main> :r [1 of 1] Compiling Main ( lec3.hs, interpreted ) Ok, one module loaded. *Main> zipWith' (\ x y -> ( x , y)) [0 .. 10] "abcdef" [(0,'a'),(1,'b'),(2,'c'),(3,'d'),(4,'e'),(5,'f')] *Main> zipWith' (\ x y -> ( x , y:"!")) [0 .. 10] "abcdef" [(0,"a!"),(1,"b!"),(2,"c!"),(3,"d!"),(4,"e!"),(5,"f!")] *Main> zipWith' (\ x y -> ( x , y + "!")) [0 .. 10] "abcdef" :19:46: error: • Couldn't match type ‘Char’ with ‘[Char]’ Expected type: [[Char]] Actual type: [Char] • In the third argument of ‘zipWith'’, namely ‘"abcdef"’ In the expression: zipWith' (\ x y -> (x, y + "!")) [0 .. 10] "abcdef" In an equation for ‘it’: it = zipWith' (\ x y -> (x, y + "!")) [0 .. 10] "abcdef" *Main> :r [1 of 1] Compiling Main ( lec3.hs, interpreted ) Ok, one module loaded. *Main> :r [1 of 1] Compiling Main ( lec3.hs, interpreted ) Ok, one module loaded. *Main> myLength' [0..23] 24 *Main> :r [1 of 1] Compiling Main ( lec3.hs, interpreted ) Ok, one module loaded. *Main> append' [1,2,3,4] [5,6,7] [1,2,3,4,5,6,7] *Main> :r [1 of 1] Compiling Main ( lec3.hs, interpreted ) Ok, one module loaded. *Main> myMap' (\ x -> x + 2) [0 .. 10] [2,3,4,5,6,7,8,9,10,11,12] *Main> :r [1 of 1] Compiling Main ( lec3.hs, interpreted ) lec3.hs:56:41: error: • Couldn't match expected type ‘a’ with actual type ‘b’ ‘b’ is a rigid type variable bound by the type signature for: myfoldl :: forall b a. (b -> a -> b) -> b -> [a] -> b at lec3.hs:54:1-41 ‘a’ is a rigid type variable bound by the type signature for: myfoldl :: forall b a. (b -> a -> b) -> b -> [a] -> b at lec3.hs:54:1-41 • In the second argument of ‘f’, namely ‘y’ In the expression: f (myfoldl f y xs) y In an equation for ‘myfoldl’: myfoldl f y (x : xs) = f (myfoldl f y xs) y • Relevant bindings include xs :: [a] (bound at lec3.hs:56:16) x :: a (bound at lec3.hs:56:14) y :: b (bound at lec3.hs:56:11) f :: b -> a -> b (bound at lec3.hs:56:9) myfoldl :: (b -> a -> b) -> b -> [a] -> b (bound at lec3.hs:55:1) | 56 | myfoldl f y (x:xs) = f (myfoldl f y xs) y | ^ Failed, no modules loaded. Prelude> :r [1 of 1] Compiling Main ( lec3.hs, interpreted ) Ok, one module loaded. *Main> :t foldl foldl :: Foldable t => (b -> a -> b) -> b -> t a -> b *Main> :t foldr foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b *Main> list1 [2,4,6,8,10] *Main> list2 [(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8),(1,9),(1,10),(2,1),(2,2),(2,3),(2,4),(2,5),(2,6),(2,7),(2,8),(2,9),(2,10),(3,1),(3,2),(3,3),(3,4),(3,5),(3,6),(3,7),(3,8),(3,9),(3,10),(4,1),(4,2),(4,3),(4,4),(4,5),(4,6),(4,7),(4,8),(4,9),(4,10),(5,1),(5,2),(5,3),(5,4),(5,5),(5,6),(5,7),(5,8),(5,9),(5,10),(6,1),(6,2),(6,3),(6,4),(6,5),(6,6),(6,7),(6,8),(6,9),(6,10),(7,1),(7,2),(7,3),(7,4),(7,5),(7,6),(7,7),(7,8),(7,9),(7,10),(8,1),(8,2),(8,3),(8,4),(8,5),(8,6),(8,7),(8,8),(8,9),(8,10),(9,1),(9,2),(9,3),(9,4),(9,5),(9,6),(9,7),(9,8),(9,9),(9,10),(10,1),(10,2),(10,3),(10,4),(10,5),(10,6),(10,7),(10,8),(10,9),(10,10)] *Main> :t ($) ($) :: (a -> b) -> a -> b *Main> inf Interupted. *Main> list3 [0,1,2,3,4] *Main> zip inf "abcde" [(0,'a'),(1,'b'),(2,'c'),(3,'d'),(4,'e')] *Main> :r [1 of 1] Compiling Main ( lec3.hs, interpreted ) Ok, one module loaded. *Main> take 10 (inf' 0) [0,1,2,3,4,5,6,7,8,9] *Main> take 10 (inf' 30) [30,31,32,33,34,35,36,37,38,39]