base-compat-0.8.0: A compatibility layer for base

Safe HaskellSafe-Inferred
LanguageHaskell98

Data.List.Compat

Synopsis

Documentation

all :: Foldable t => (a -> Bool) -> t a -> Bool

Determines whether all elements of the structure satisfy the predicate.

and :: Foldable t => t Bool -> Bool

and returns the conjunction of a container of Bools. For the result to be True, the container must be finite; False, however, results from a False value finitely far from the left end.

any :: Foldable t => (a -> Bool) -> t a -> Bool

Determines whether any element of the structure satisfies the predicate.

concat :: Foldable t => t [a] -> [a]

The concatenation of all the elements of a container of lists.

concatMap :: Foldable t => (a -> [b]) -> t a -> [b]

Map a function over all the elements of a container and concatenate the resulting lists.

elem :: (Foldable t, Eq a) => a -> t a -> Bool

Does the element occur in the structure?

find :: Foldable t => (a -> Bool) -> t a -> Maybe a

The find function takes a predicate and a structure and returns the leftmost element of the structure matching the predicate, or Nothing if there is no such element.

foldl :: Foldable t => forall b a. (b -> a -> b) -> b -> t a -> b

Left-associative fold of a structure.

foldl f z = foldl f z . toList

foldl' :: Foldable t => forall b a. (b -> a -> b) -> b -> t a -> b

Left-associative fold of a structure. but with strict application of the operator.

foldl f z = foldl' f z . toList

foldl1 :: Foldable t => forall a. (a -> a -> a) -> t a -> a

A variant of foldl that has no base case, and thus may only be applied to non-empty structures.

foldl1 f = foldl1 f . toList

foldr :: Foldable t => forall a b. (a -> b -> b) -> b -> t a -> b

Right-associative fold of a structure.

foldr f z = foldr f z . toList

foldr1 :: Foldable t => forall a. (a -> a -> a) -> t a -> a

A variant of foldr that has no base case, and thus may only be applied to non-empty structures.

foldr1 f = foldr1 f . toList

length :: Foldable t => t a -> Int Source

Returns the size/length of a finite structure as an Int. The default implementation is optimized for structures that are similar to cons-lists, because there is no general way to do better.

maximum :: (Foldable t, Ord a) => t a -> a

The largest element of a non-empty structure.

maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a

The largest element of a non-empty structure with respect to the given comparison function.

minimum :: (Foldable t, Ord a) => t a -> a

The least element of a non-empty structure.

minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a

The least element of a non-empty structure with respect to the given comparison function.

notElem :: (Foldable t, Eq a) => a -> t a -> Bool

notElem is the negation of elem.

null :: Foldable t => t a -> Bool Source

Test whether the structure is empty. The default implementation is optimized for structures that are similar to cons-lists, because there is no general way to do better.

or :: Foldable t => t Bool -> Bool

or returns the disjunction of a container of Bools. For the result to be False, the container must be finite; True, however, results from a True value finitely far from the left end.

product :: (Foldable t, Num a) => t a -> a

The product function computes the product of the numbers of a structure.

sum :: (Foldable t, Num a) => t a -> a

The sum function computes the sum of the numbers of a structure.

mapAccumL :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c)

The mapAccumL function behaves like a combination of fmap and foldl; it applies a function to each element of a structure, passing an accumulating parameter from left to right, and returning a final value of this accumulator together with the new structure.

mapAccumR :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c)

The mapAccumR function behaves like a combination of fmap and foldr; it applies a function to each element of a structure, passing an accumulating parameter from right to left, and returning a final value of this accumulator together with the new structure.

isSubsequenceOf :: Eq a => [a] -> [a] -> Bool Source

The isSubsequenceOf function takes two lists and returns True if the first list is a subsequence of the second list.

isSubsequenceOf x y is equivalent to elem x (subsequences y).

Since: 4.8.0.0

Examples

>>> isSubsequenceOf "GHC" "The Glorious Haskell Compiler"
True
>>> isSubsequenceOf ['a','d'..'z'] ['a'..'z']
True
>>> isSubsequenceOf [1..10] [10,9..0]
False

sortOn :: Ord b => (a -> b) -> [a] -> [a] Source

Sort a list by comparing the results of a key function applied to each element. sortOn f is equivalent to sortBy . comparing f, but has the performance advantage of only evaluating f once for each element in the input list. This is called the decorate-sort-undecorate paradigm, or Schwartzian transform.

Since: 4.8.0.0

uncons :: [a] -> Maybe (a, [a]) Source

Decompose a list into its head and tail. If the list is empty, returns Nothing. If the list is non-empty, returns Just (x, xs), where x is the head of the list and xs its tail.

Since: 4.8.0.0

scanl' :: (b -> a -> b) -> b -> [a] -> [b] Source

A strictly accumulating version of scanl