Portability | portable |
---|---|

Stability | provisional |

Maintainer | Edward Kmett <ekmett@gmail.com> |

Safe Haskell | Safe-Inferred |

Traversals for manipulating parts of a list.

- _head :: Simple Lens [a] a
- _tail :: Simple Lens [a] [a]
- _last :: Simple Lens [a] a
- _init :: Simple Lens [a] [a]
- traverseHead :: SimpleIndexedTraversal Int [a] a
- traverseTail :: SimpleIndexedTraversal Int [a] a
- traverseInit :: SimpleIndexedTraversal Int [a] a
- traverseLast :: SimpleIndexedTraversal Int [a] a

# Partial Lenses

# Traversals

traverseHead :: SimpleIndexedTraversal Int [a] aSource

A traversal for reading and writing to the head of a list

The position of the head in the original list (0) is available as the index.

`>>>`

[2,2,3]`traverseHead +~ 1 $ [1,2,3]`

`traverseHead`

::`Applicative`

f => (a -> f a) -> [a] -> f [a]

traverseTail :: SimpleIndexedTraversal Int [a] aSource

A traversal for editing the tail of a list

The position of each element *in the original list* is available as the index.

`>>>`

[1,3,4]`traverseTail +~ 1 $ [1,2,3]`

`traverseTail`

::`Applicative`

f => (a -> f a) -> [a] -> f [a]

traverseInit :: SimpleIndexedTraversal Int [a] aSource

A traversal of all but the last element of a list

The position of each element is available as the index.

`>>>`

[2,3,3]`traverseInit +~ 1 $ [1,2,3]`

`traverseInit`

::`Applicative`

f => (a -> f a) -> [a] -> f [a]

traverseLast :: SimpleIndexedTraversal Int [a] aSource

A traversal the last element in a list

The position of the last element in the original list is available as the index.

`>>>`

[1,2,4]`traverseLast +~ 1 $ [1,2,3]`

`traverseLast`

::`Applicative`

f => (a -> f a) -> [a] -> f [a]