lens-3.9.2: Lenses, Folds and Traversals

Portability non-portable experimental Edward Kmett None

Data.Sequence.Lens

Description

Synopsis

# Documentation

viewL :: Iso (Seq a) (Seq b) (ViewL a) (ViewL b)Source

A `Seq` is isomorphic to a `ViewL`

``viewl` m ≡ m `^.` `viewL``
````>>> ````Seq.fromList [a,b,c] ^. viewL
```a :< fromList [b,c]
```
````>>> ````Seq.empty ^. viewL
```EmptyL
```
````>>> ````EmptyL ^. from viewL
```fromList []
```
````>>> ````review viewL \$ a :< fromList [b,c]
```fromList [a,b,c]
```

viewR :: Iso (Seq a) (Seq b) (ViewR a) (ViewR b)Source

A `Seq` is isomorphic to a `ViewR`

``viewr` m ≡ m `^.` `viewR``
````>>> ````Seq.fromList [a,b,c] ^. viewR
```fromList [a,b] :> c
```
````>>> ````Seq.empty ^. viewR
```EmptyR
```
````>>> ````EmptyR ^. from viewR
```fromList []
```
````>>> ````review viewR \$ fromList [a,b] :> c
```fromList [a,b,c]
```

sliced :: Int -> Int -> IndexedTraversal' Int (Seq a) aSource

Traverse all the elements numbered from `i` to `j` of a `Seq`

````>>> ````fromList [a,b,c,d,e] & sliced 1 3 %~ f
```fromList [a,f b,f c,d,e]
```

Traverse the first `n` elements of a `Seq`

````>>> ````fromList [a,b,c,d,e] ^.. slicedTo 2
```[a,b]
```
````>>> ````fromList [a,b,c,d,e] & slicedTo 2 %~ f
```fromList [f a,f b,c,d,e]
```
````>>> ````fromList [a,b,c,d,e] & slicedTo 10 .~ x
```fromList [x,x,x,x,x]
```

Traverse all but the first `n` elements of a `Seq`

````>>> ````fromList [a,b,c,d,e] ^.. slicedFrom 2
```[c,d,e]
```
````>>> ````fromList [a,b,c,d,e] & slicedFrom 2 %~ f
```fromList [a,b,f c,f d,f e]
```
````>>> ````fromList [a,b,c,d,e] & slicedFrom 10 .~ x
```fromList [a,b,c,d,e]
```