Basic functions --------------- div, mod :: Integral a => a -> a -> a even, odd :: Integral a => a -> Bool (+), (*), (-), (/) :: Num a => a -> a -> a (<), (<=), (>), (>=) :: Ord => a -> a -> Bool (==), (/=) :: Eq a => a -> a -> Bool (&&), (||) :: Bool -> Bool -> Bool not :: Bool -> Bool max, min :: Ord a => a -> a -> a isAlpha, isAlphaNum, isLower, isUpper, isDigit :: Char -> Bool toLower, toUpper :: Char -> Char ord :: Char -> Int chr :: Int -> Char Library functions ----------------- sum, product :: (Num a) => [a] -> a and, or :: [Bool] -> Bool sum [1.0,2.0,3.0] = 6.0 and [True,False,True] = False product [1,2,3,4] = 24 or [True,False,True] = True maximum, minimum :: (Ord a) => [a] -> a reverse :: [a] -> [a] maximum [3,1,4,2] = 4 reverse "goodbye" = "eybdoog" minimum [3,1,4,2] = 1 concat :: [[a]] -> [a] (++) :: [a] -> [a] -> [a] concat ["go","od","bye"] = "goodbye" "good" ++ "bye" = "goodbye" (!!) :: [a] -> Int -> a length :: [a] -> Int [9,7,5] !! 1 = 7 length [9,7,5] = 3 head :: [a] -> a tail :: [a] -> [a] head "goodbye" = 'g' tail "goodbye" = "oodbye" init :: [a] -> [a] last :: [a] -> a init "goodbye" = "goodby" last "goodbye" = 'e' takeWhile :: (a->Bool) -> [a] -> [a] take :: Int -> [a] -> [a] takeWhile isLower "goodBye" = "good" take 4 "goodbye" = "good" dropWhile :: (a->Bool) -> [a] -> [a] drop :: Int -> [a] -> [a] dropWhile isLower "goodBye" = "Bye" drop 4 "goodbye" = "bye" elem :: (Eq a) => a -> [a] -> Bool replicate :: Int -> a -> [a] elem 'd' "goodbye" = True replicate 5 '*' = "*****" zip :: [a] -> [b] -> [(a,b)] zip [1,2,3,4] [1,4,9] = [(1,1),(2,4),(3,9)]