GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help Prelude> floor (sqrt (fromIntegral 5)) 2 Prelude> floor (sqrt $ fromIntegral 5) 2 Prelude> floor $ sqrt $ fromIntegral 5 2 Prelude> floor . sqrt . fromIntegral $ 5 2 Prelude> floor . sqrt . fromIntegral 5 :12:1: Non type-variable argument in the constraint: Num (a -> a) (Use FlexibleContexts to permit this) When checking that ‘it’ has the inferred type it :: forall c a a1. (Floating a1, Integral c, Num (a -> a1), RealFrac a1) => a -> c Prelude> (floor . sqrt . fromIntegral) 5 2 Prelude> map ($2) [(4+), succ, (^3)] [6,3,8] Prelude> map ($ 2) [(4+), succ, (^3)] [6,3,8] Prelude> (^2) 4 16 Prelude> (^2) 3 9 Prelude> (2^) 3 8 Prelude> map (^2) [1..5] [1,4,9,16,25] Prelude> map (succ . (^2)) [1..5] [2,5,10,17,26] Prelude> map ((-5) . (^2)) [1..5] :21:1: Non type-variable argument in the constraint: Num (b -> b) (Use FlexibleContexts to permit this) When checking that ‘it’ has the inferred type it :: forall b b1. (Enum b1, Num b1, Num (b1 -> b)) => [b] Prelude> map ((+5) . (^2)) [1..5] [6,9,14,21,30] Prelude> map (\ x -> x^2-5) [1..5] [-4,-1,4,11,20] Prelude> map (\ x -> x^2+5) [1..5] [6,9,14,21,30] Prelude> :cd C:\Users\Dari\Documents Prelude> :load "main.hs" [1 of 1] Compiling Main ( main.hs, interpreted ) Ok, modules loaded: Main. *Main> count' 5 [1,2,3,4,5,5,4,5,6,5] 4 *Main> :r Ok, modules loaded: Main. *Main> take 10 $ repeat 5 [5,5,5,5,5,5,5,5,5,5] *Main> sum [1..5 :31:10: parse error (possibly incorrect indentation or mismatched brackets) *Main> sum [1..5] 15 *Main> product [1..5] 120 *Main> foldr (*) 1 [1..5] 120 *Main> zip [1..5] "abcdefghi" [(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e')] *Main> zip [1..] "abcdefghi" [(1,'a'),(2,'b'),(3,'c'),(4,'d'),(5,'e'),(6,'f'),(7,'g'),(8,'h'),(9,'i')] *Main> zipWith (+) [1,2,3,4,5] [10..] [11,13,15,17,19] *Main> zipWith ($) [(4+), (^3), succ] [2..10] [6,27,5] *Main> zipWith elem [4,3,5] [[1,2,3,4], [5,6,7,8], [20,19..10]] [True,False,False] *Main> :r [1 of 1] Compiling Main ( main.hs, interpreted ) Ok, modules loaded: Main. *Main> sumProducts [[1..3],[],[-2,3,0,5,1]] :41:1: Not in scope: ‘sumProducts’ Perhaps you meant ‘sumProduct’ (line 4) *Main> sumProduct [[1..3],[],[-2,3,0,5,1]] 7 *Main> product [1,2,3,4,5] 120 *Main> let factorial n = product [1..n] *Main> factorial 5 120 *Main> :r [1 of 1] Compiling Main ( main.hs, interpreted ) Ok, modules loaded: Main. *Main> :r [1 of 1] Compiling Main ( main.hs, interpreted ) main.hs:5:18: No instance for (Num a) arising from a use of ‘sum’ Possible fix: add (Num a) to the context of the type signature for sumProducts :: [[a]] -> a In the expression: sum In the expression: sum $ map product ls In an equation for ‘sumProducts’: sumProducts ls = sum $ map product ls Failed, modules loaded: none. Prelude> :t sum sum :: (Num a, Foldable t) => t a -> a Prelude> :r [1 of 1] Compiling Main ( main.hs, interpreted ) main.hs:22:39: No instance for (Integral a) arising from a use of ‘mod’ Possible fix: add (Integral a) to the context of the type signature for maybePlus :: Maybe a -> Maybe a -> Maybe a In the first argument of ‘Just’, namely ‘(x `mod` y)’ In the expression: Just (x `mod` y) In an equation for ‘maybePlus’: maybePlus (Just x) (Just y) = Just (x `mod` y) Failed, modules loaded: none. Prelude> :r [1 of 1] Compiling Main ( main.hs, interpreted ) Ok, modules loaded: Main. *Main> :t : not an expression: ‘’ *Main> :t length length :: Foldable t => t a -> Int *Main> :r [1 of 1] Compiling Main ( main.hs, interpreted ) main.hs:28:55: Not in scope: ‘m’ Failed, modules loaded: none. Prelude> :r [1 of 1] Compiling Main ( main.hs, interpreted ) main.hs:28:48: Occurs check: cannot construct the infinite type: a ~ [a] Expected type: [[a]] Actual type: [[[a]]] Relevant bindings include other :: [[[a]]] (bound at main.hs:28:17) first :: [[a]] (bound at main.hs:28:11) mainDiag :: [[[a]]] -> [[a]] (bound at main.hs:27:1) In the second argument of ‘map’, namely ‘other’ In the second argument of ‘(:)’, namely ‘map tail other’ Failed, modules loaded: none. Prelude> :r [1 of 1] Compiling Main ( main.hs, interpreted ) main.hs:28:26: Couldn't match expected type ‘[[a]] -> [t]’ with actual type ‘[a]’ Relevant bindings include other :: [[a]] (bound at main.hs:28:17) first :: [a] (bound at main.hs:28:11) mainDiag :: [[a]] -> [t] (bound at main.hs:27:1) The first argument of ($) takes one argument, but its type ‘[a]’ has none In the expression: head first : mainDiag $ map tail other In an equation for ‘mainDiag’: mainDiag (first : other) = head first : mainDiag $ map tail other main.hs:28:39: Couldn't match expected type ‘[a]’ with actual type ‘[[a]] -> [t]’ Relevant bindings include other :: [[a]] (bound at main.hs:28:17) first :: [a] (bound at main.hs:28:11) mainDiag :: [[a]] -> [t] (bound at main.hs:27:1) Probable cause: ‘mainDiag’ is applied to too few arguments In the second argument of ‘(:)’, namely ‘mainDiag’ In the expression: head first : mainDiag Failed, modules loaded: none. Prelude> :r [1 of 1] Compiling Main ( main.hs, interpreted ) Ok, modules loaded: Main. *Main> mainDiag [[1..3],[4..6],[7..9]] [1,5,9] *Main> :r [1 of 1] Compiling Main ( main.hs, interpreted ) Failed, modules loaded: none. main.hs:29:27: Not in scope: ‘m’ Prelude> :r main.hs:29:27: Not in scope: ‘m’ [1 of 1] Compiling Main ( main.hs, interpreted ) Failed, modules loaded: none. Prelude> :r [1 of 1] Compiling Main ( main.hs, interpreted ) Ok, modules loaded: Main. *Main> mainDiag [[1..3],[4..6],[7..9]] [1,5,9] *Main> :r [1 of 1] Compiling Main ( main.hs, interpreted ) Ok, modules loaded: Main. *Main> sndDiag [[1..3],[4..6],[7..9]] [3,5,7] *Main> :r [1 of 1] Compiling Main ( main.hs, interpreted ) Ok, modules loaded: Main. *Main> :r Ok, modules loaded: Main. *Main> let functionList = map (\x -> compose succ x) [1..] :69:31: Not in scope: ‘compose’ Perhaps you meant one of these: ‘composeN’ (line 33), ‘compare’ (imported from Prelude) *Main> let functionList = map (\x -> composeN succ x) [1..] *Main> let functionList = map (succ `composeN`) [1..] *Main> take 5 $ map ($1) functionList [2,3,4,5,6] *Main>