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

Stability | provisional |

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

Safe Haskell | Safe-Infered |

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]
- interspersed :: a -> Getter [a] [a]
- intercalated :: [a] -> Getter [[a]] [a]
- traverseHead :: SimpleTraversal [a] a
- traverseTail :: SimpleTraversal [a] a
- traverseInit :: SimpleTraversal [a] a
- traverseLast :: SimpleTraversal [a] a

# Documentation

_head :: Simple Lens [a] aSource

A lens reading and writing to the head of a *non-empty* list

ghci> [1,2,3]^._head 1

_tail :: Simple Lens [a] [a]Source

A lens reading and writing to the tail of a *non-empty* list

ghci> _tail <~ [3,4,5] $ [1,2] [1,3,4,5]

_init :: Simple Lens [a] [a]Source

A lens reading and replacing all but the a last element of a *non-empty* list

interspersed :: a -> Getter [a] [a]Source

Obtain a version of the list with the supplied value interspersed.

ghci> "abcde"^.interspersed ',' "a,b,c,d,e"

xs^.interspersed a = intersperse a xs

intercalated :: [a] -> Getter [[a]] [a]Source

Obtain a version of the list with the supplied value intercalated

traverseHead :: SimpleTraversal [a] aSource

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

traverseHead :: Applicative f => (a -> f a) -> [a] -> f [a]

traverseTail :: SimpleTraversal [a] aSource

Traversal for editing the tail of a list.

traverseTail :: Applicative f => (a -> f a) -> [a] -> f [a]

traverseInit :: SimpleTraversal [a] aSource

Traverse all but the last element of a list

traverseInit :: Applicative f => (a -> f a) -> [a] -> f [a]

traverseLast :: SimpleTraversal [a] aSource

Traverse the last element in a list.

traverseLast :: Applicative f => (a -> f a) -> [a] -> f [a]