lens-3.4: Lenses, Folds and Traversals

Portabilityportable
Stabilityprovisional
MaintainerEdward Kmett <ekmett@gmail.com>
Safe HaskellSafe-Inferred

Data.List.Lens

Contents

Description

Traversals for manipulating parts of a list.

Synopsis

Partial Lenses

_head :: SimpleIndexedTraversal Int [a] aSource

A Traversal reading and writing to the head of a non-empty list.

>>> [1,2,3]^!?_head
1

_tail :: Simple Traversal [a] [a]Source

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

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

_last :: SimpleIndexedTraversal Int [a] aSource

A Traversal reading and writing to the last element of a non-empty list

>>> [1,2]^!?_last
2

_init :: Simple Traversal [a] [a]Source

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

>>> [1,2,3,4]^!?_init
[1,2,3]