lens-4.11.1: Lenses, Folds and Traversals

Copyright(C) 2012-15 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityprovisional
Portabilityportable
Safe HaskellNone
LanguageHaskell98

Data.List.Lens

Description

Traversals for manipulating parts of a list.

Synopsis

Documentation

prefixed :: Eq a => [a] -> Prism' [a] [a] Source

A Prism stripping a prefix from a list when used as a Traversal, or prepending that prefix when run backwards:

>>> "preview" ^? prefixed "pre"
Just "view"
>>> "review" ^? prefixed "pre"
Nothing
>>> prefixed "pre" # "amble"
"preamble"

suffixed :: Eq a => [a] -> Prism' [a] [a] Source

A Prism stripping a suffix from a list when used as a Traversal, or appending that suffix when run backwards:

>>> "review" ^? suffixed "view"
Just "re"
>>> "review" ^? suffixed "tire"
Nothing
>>> suffixed ".o" # "hello"
"hello.o"

stripSuffix :: Eq a => [a] -> [a] -> Maybe [a] Source