\ :t 1 1 :: Num a => a -- tip numeric \ :t 'a' 'a' :: Char \ :t True True :: Bool \ :t False False :: Bool \ :t 1.5 1.5 :: Fractional a => a -- tip numeric fracțional \ :t [1,2,3] [1,2,3] :: Num a => [a] -- listă de numere \ :t ('a', True) ('a', True) :: (Char, Bool) -- pereche de carcater și boolean \ :t [1..] [1..] :: (Num a, Enum a) => [a] \ :t [1,1.5..] [1,1.5..] :: (Fractional a, Enum a) => [a] \ :t (1, 1.5) (1, 1.5) :: (Fractional b, Num a) => (a, b) \ fst (1, 1.5) 1 \ snd (1, 1.5) 1.5 \ head [1,2,3,4,5] 1 \ tail [1,2,3,4,5] [2,3,4,5] \ length [1,2,3,4,5] 5 \ [1,2,3,4,5] !! 3 -- index 3 (0-based) 4 \ 1 + 2 3 \ 2 < 3 True \ :t "abcd" "abcd" :: String \ :i String type String :: * type String = [Char] -- un String este o listă de Char -- Defined in `GHC.Base' \ head "abcd" 'a' \ tail "abcd" "bcd" \ "abc" ++ "def" "abcdef" \ "a" : "bcd" :29:7: error: [GHC-83865] * Couldn't match type `Char' with `[Char]' Expected: [String] Actual: String * In the second argument of `(:)', namely `"bcd"' In the expression: "a" : "bcd" In an equation for `it': it = "a" : "bcd" \ 'a' : "bcd" "abcd" \ \ add1 2 3 5 \ map (add1 1) [1..5] [2,3,4,5,6] \ :t add1 add1 :: Integer -> Integer -> Integer -- add1 este o funcție care primește un întreg și întoarce o funcție care primește un întreg și întoarce un întreg \ :t add2 add2 :: Integer -> Integer -> Integer \ ((add1 2) 3) 5 \ addX 1 2 3 \ addX 1 10 11 \ addX 5 5 *** Exception: a.hs:(11,1)-(13,13): Non-exhaustive patterns in function addX \ (a,b) = (1,2) -- legare folosind pattern-match \ a 1 \ (_,c) = (1,2) \ c 2 \ [[], [1,2], [1..], []] !! 3 -- elementul de la index 2 nu se evaluează [] \ len3c [[], [1,2], [1..], []] 4