A functional programming language with parametric polymorphism and lazy evaluation. The code examples here use the Haskell 2010 Language Report specification.
The function
zip :: [a] -> [b] -> [(a,b)] pairs corresponding list positions, stopping when either input ends. Pairing a finite list with [0..] attaches its zero-based indices without constructing an infinite result. With the unbounded Integer index type this avoids index overflow for arbitrarily long finite inputs.The higher-order function
takeWhile :: (a -> Bool) -> [a] -> [a] retains the longest initial segment whose elements all satisfy its predicate. It stops at the first failure and does not resume later. Thus it differs from a list filter, which tests later elements as well.The higher-order function
iterate :: (a -> a) -> a -> [a], satisfying iterate f x = x : iterate f (f x). Its result begins with the initial value and continues with successive applications. Lazy evaluation permits finite prefixes of this infinite list to be observed whenever the necessary applications terminate.The higher-order function with type
(a -> [b]) -> [a] -> [b] and value concat (map f xs). It replaces each input element by a list and concatenates those lists in input order. A direct definition is concatMap f = foldr (\x rest -> f x ++ rest) []. This formulation processes an input element's produced list once; it need not repeatedly append an already accumulated output prefix.A partially applied infix operator:
(a op) means \x -> a op x, and (op b) means \x -> x op b, subject to Haskell's syntax rules. In particular, (f .) maps a function g to the function composition f . g. Composing such a section with a curried binary function composes at two argument levels: ((f .) . g) x y = f (g x y) on total inputs.[ref]Haskell 2010 Language Report. §3.5, Sections
The automatically available standard module of Haskell, supplying basic types, classes and operations such as list folds, arithmetic and list comprehension support. A program can explicitly hide an imported name when providing an alternative definition. The reference definitions specify behavior, rather than requiring a particular implementation strategy.[ref]
Haskell 2010 Language Report. Chapter 9, introductory paragraphs and module Prelude exports
