poole@CPSC-M-POOLE01 haskell % ghci GHCi, version 9.4.8: https://www.haskell.org/ghc/ :? for help ghci> :l Lists3 [1 of 1] Compiling Lists3 ( Lists3.hs, interpreted ) Ok, one module loaded. ghci> :type myfoldr (&&) myfoldr (&&) :: Bool -> [Bool] -> Bool ghci> myfoldr (\ x y -> 10*x : y) [] [1,2,3,4] [10,20,30,40] ghci> myfoldr (\ x y -> 10*x + y) 0 [1,2,3,4] 100 ghci> myfoldr (\ x y -> x + 10*y) 0 [1,2,3,4] 4321 ghci> :l Lists4 [1 of 1] Compiling Lists4 ( Lists4.hs, interpreted ) Ok, one module loaded. ghci> r2 [1,2] [3,4] [4,3,1,2] ghci> rev [1,2,4,6,11,23,45,56] [56,45,23,11,6,4,2,1] ghci> myfoldl (+) 0 [1..10] 55 ghci> myfoldl (:) [] [1..10] :12:9: error: • Couldn't match type ‘a’ with ‘[a]’ Expected: [a] -> [[a]] -> [a] Actual: [a] -> [[a]] -> [[a]] ‘a’ is a rigid type variable bound by the inferred type of it :: [a] at :12:1-22 • In the first argument of ‘myfoldl’, namely ‘(:)’ In the expression: myfoldl (:) [] [1 .. 10] In an equation for ‘it’: it = myfoldl (:) [] [1 .. 10] • Relevant bindings include it :: [a] (bound at :12:1) ghci> myfoldl (flip (:)) [] [1..10] [10,9,8,7,6,5,4,3,2,1] ghci> myfoldl consi [] [1..10] [10,9,8,7,6,5,4,3,2,1] ghci> :type re re :: [t] -> [t] ghci> ch2dig '4' 4 ghci> ch2dig 'e' 53 ghci> myfoldl (\n c -> 10*n + ch2dig c) 0 "1234" 1234 ghci> str2int "-543212345" -543212345 ghci> :l Lists3 [1 of 1] Compiling Lists3 ( Lists3.hs, interpreted ) Ok, one module loaded. ghci> :type myfoldr myfoldr :: (t1 -> t2 -> t2) -> t2 -> [t1] -> t2 ghci> :type myfoldr (&&) myfoldr (&&) :: Bool -> [Bool] -> Bool ghci> :type (&&) (&&) :: Bool -> Bool -> Bool ghci> :type myfoldr (+) myfoldr (+) :: Num t2 => t2 -> [t2] -> t2 ghci> a = (+4) ghci> a 3 7