\> 1 1 \> 1.1 1.1 \> :t 1 1 :: Num a => a -- 1 este de un tip oarecare, cu condiția să fie un tip numeric \> :t True True :: Bool \> :t 'a' 'a' :: Char \> :t "abc" "abc" :: String \> :t (1, "abc") (1, "abc") :: Num a => (a, String) \> :t (True, 'a', (5, 6)) (True, 'a', (5, 6)) :: (Num a, Num b) => (Bool, Char, (a, b)) \> :t [1,2,3,4] [1,2,3,4] :: Num a => [a] -- este o listă de elemente de tip t, iar t este un tip numeric \> :t [1,2,3,True] --- listele trebuie să aibă tip uniform :1:2: error: [GHC-39999] * No instance for `Num Bool' arising from the literal `1' * In the expression: 1 In the expression: [1, 2, 3, True] \> [0,5..100] [0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100] \> head [1..5] 1 \> tail [1..5] [2,3,4,5] \> fst (1, 'a') 1 \> snd (1, 'a') 'a' \> :i String type String :: * type String = [Char] -- String este o listă de Char -- Defined in `GHC.Base' \> head "abcd" 'a' \> 'a' : "bcd" "abcd" \> "abcd" ++ "efgh" "abcdefgh" \> 1 + 2 3 \> 1 / 2 / 3 -- / are asociativitate stânga, vezi :i / 0.16666666666666666 \> head (tail "string") 't' \> head $ tail "string" 't' \> map (+1) $ tail $ filter (>5) [2,7,4,8,3,10] -- aplicare parțială > pe al doilea argument [9,11] \> map (+1) $ tail $ filter (5>) [2,7,4,8,3,10] -- aplicare parțială > pe primul argument [5,4] \> map (/2) [1..10] [0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0] \> zipWith (+) [1..5] [6..10] -- utilizare operator ca funcție [7,9,11,13,15] \> (+1) `map` [1..5] -- utilizare funcție ca operator infixat [2,3,4,5,6] \> 5 `mod` 2 1