*Main> summation [1 .. 100] 5050 *Main> summation' [1 .. 100] 5050 *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) lec4.hs:56:14: error: • Couldn't match expected type ‘Int’ with actual type ‘a’ ‘a’ is a rigid type variable bound by the type signature for: length'' :: forall a. [a] -> Int at lec4.hs:55:1-22 • In the expression: foldr' (\ x r -> x + r) 0 l In an equation for ‘length''’: length'' l = foldr' (\ x r -> x + r) 0 l • Relevant bindings include l :: [a] (bound at lec4.hs:56:10) length'' :: [a] -> Int (bound at lec4.hs:56:1) | 56 | length'' l = foldr' (\ x r -> x + r) 0 l | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Failed, no modules loaded. Prelude> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) lec4.hs:56:14: error: • Couldn't match expected type ‘Int’ with actual type ‘a’ ‘a’ is a rigid type variable bound by the type signature for: length'' :: forall a. [a] -> Int at lec4.hs:55:1-22 • In the expression: foldr' (\ x r -> x + r) 0 l In an equation for ‘length''’: length'' l = foldr' (\ x r -> x + r) 0 l • Relevant bindings include l :: [a] (bound at lec4.hs:56:10) length'' :: [a] -> Int (bound at lec4.hs:56:1) | 56 | length'' l = foldr' (\ x r -> x + r) 0 l | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Failed, no modules loaded. Prelude> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> length'' [1 .. 100] 100 *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> append' [1 .. 10] [11 .. 20] [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20] *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> append' [1 .. 10] [11 .. 20] [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20] *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> map'' (\ x -> x + 1) [1 .. 10] [2,3,4,5,6,7,8,9,10,11] *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> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> summation'' [1 .. 100] 5050 *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> reverse'' [1 .. 10] [10,9,8,7,6,5,4,3,2,1] *Main> reverse''' [1 .. 10] [10,9,8,7,6,5,4,3,2,1] *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> :t P P :: a -> b -> Pair a b *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> first (P 1 True) 1 *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> :t T T :: Bool' *Main> :t F F :: Bool' *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> :t Nil Nil :: List a *Main> :t Cons Cons :: a -> List a -> List a *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> my_append l1 l2 :36:1: error: • No instance for (Show (List Int)) arising from a use of ‘print’ • In a stmt of an interactive GHCi command: print it *Main> T :37:1: error: • No instance for (Show Bool') arising from a use of ‘print’ • In a stmt of an interactive GHCi command: print it *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> T T *Main> my_append l1 l2 Cons 1 (Cons 2 (Cons 3 (Cons 4 (Cons 5 (Cons 6 Nil))))) *Main> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) lec4.hs:98:23: error: • Can't make a derived instance of ‘Foldable List’: You need DeriveFoldable to derive an instance for this class • In the data declaration for ‘List’ | 98 | deriving (Show, Eq, Foldable) | ^^^^^^^^ Failed, no modules loaded. Prelude> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) lec4.hs:98:33: error: Not in scope: type constructor or class ‘DeriveFoldable’ | 98 | deriving (Show, Eq, Foldable, DeriveFoldable) | ^^^^^^^^^^^^^^ Failed, no modules loaded. Prelude> :r [1 of 1] Compiling Main ( lec4.hs, interpreted ) Ok, one module loaded. *Main> tr1 Node 5 (Node 4 Leaf Leaf) (Node 6 (Node 7 Leaf Leaf) Leaf)