rio-0.1.8.0: A standard library for Haskell

Safe Haskell | Safe
Language | Haskell2010

RIO.List.Partial

Contents

- Basic functions
- Reducing lists (folds)
  - Special folds
- Building lists
  - Scans
- Indexing lists

Synopsis

- head :: [a] -> a
- last :: [a] -> a
- tail :: [a] -> [a]
- init :: [a] -> [a]
- foldl1 :: Foldable t => (a -> a -> a) -> t a -> a
- foldl1' :: (a -> a -> a) -> [a] -> a
- foldr1 :: Foldable t => (a -> a -> a) -> t a -> a
- maximum :: (Foldable t, Ord a) => t a -> a
- minimum :: (Foldable t, Ord a) => t a -> a
- maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a
- minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a
- scanl1 :: (a -> a -> a) -> [a] -> [a]
- scanr1 :: (a -> a -> a) -> [a] -> [a]
- (!!) :: [a] -> Int -> a

# Basic functions

head :: [a] -> a Source #

Extract the first element of a list, which must be non-empty.

last :: [a] -> a Source #

Extract the last element of a list, which must be finite and non-empty.

tail :: [a] -> [a] Source #

Extract the elements after the head of a list, which must be non-empty.

init :: [a] -> [a] Source #

Return all the elements of a list except the last one. The list must be non-empty.

# Reducing lists (folds)

foldl1 :: Foldable t => (a -> a -> a) -> t a -> a Source #

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

    foldl1 f = foldl1 f . toList

foldl1' :: (a -> a -> a) -> [a] -> a Source #

A strict version of `foldl1`

foldr1 :: Foldable t => (a -> a -> a) -> t a -> a Source #

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

    foldr1 f = foldr1 f . toList

## Special folds

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

The largest element of a non-empty structure.

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

The least element of a non-empty structure.

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

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

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

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

# Building lists

## Scans

scanl1 :: (a -> a -> a) -> [a] -> [a] Source #

`scanl1` is a variant of `scanl` that has no starting value argument:

    scanl1 f [x1, x2, ...] == [x1, x1 `f` x2, ...]

scanr1 :: (a -> a -> a) -> [a] -> [a] Source #

`scanr1` is a variant of `scanr` that has no starting value argument.

# Indexing lists

(!!) :: [a] -> Int -> a infixl 9 Source #

List index (subscript) operator, starting from 0. It is an instance of the more general `genericIndex`, which takes an index of any integral type.