HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleoptics-core-0.4.1.1Haskell2010

Data.Sequence.Optics

This module defines optics for constructing and manipulating finite Seqs.

  • 6 values
valueviewL :: Iso (Seq a) (Seq b) (ViewL a) (ViewL b)
#

A Seq is isomorphic to a ViewL

viewl m ≡ m ^. viewL
Example1 expression
Seq.fromList [1,2,3] ^. viewL1 :< fromList [2,3]
Example1 expression
Seq.empty ^. viewLEmptyL
Example1 expression
EmptyL ^. re viewLfromList []
Example1 expression
review viewL $ 1 Seq.:< Seq.fromList [2,3]fromList [1,2,3]
valueviewR :: Iso (Seq a) (Seq b) (ViewR a) (ViewR b)
#

A Seq is isomorphic to a ViewR

viewr m ≡ m ^. viewR
Example1 expression
Seq.fromList [1,2,3] ^. viewRfromList [1,2] :> 3
Example1 expression
Seq.empty ^. viewREmptyR
Example1 expression
EmptyR ^. re viewRfromList []
Example1 expression
review viewR $ Seq.fromList [1,2] Seq.:> 3fromList [1,2,3]
valuesliced :: Int -> Int -> IxTraversal' Int (Seq a) a
#

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

Example1 expression
Seq.fromList [1,2,3,4,5] & sliced 1 3 %~ (*10)fromList [1,20,30,4,5]
Example1 expression
Seq.fromList [1,2,3,4,5] ^.. sliced 1 3[2,3]
Example1 expression
Seq.fromList [1,2,3,4,5] & sliced 1 3 .~ 0fromList [1,0,0,4,5]
valueslicedTo :: Int -> IxTraversal' Int (Seq a) a
#

Traverse the first n elements of a Seq

Example1 expression
Seq.fromList [1,2,3,4,5] ^.. slicedTo 2[1,2]
Example1 expression
Seq.fromList [1,2,3,4,5] & slicedTo 2 %~ (*10)fromList [10,20,3,4,5]
Example1 expression
Seq.fromList [1,2,4,5,6] & slicedTo 10 .~ 0fromList [0,0,0,0,0]
valueslicedFrom :: Int -> IxTraversal' Int (Seq a) a
#

Traverse all but the first n elements of a Seq

Example1 expression
Seq.fromList [1,2,3,4,5] ^.. slicedFrom 2[3,4,5]
Example1 expression
Seq.fromList [1,2,3,4,5] & slicedFrom 2 %~ (*10)fromList [1,2,30,40,50]
Example1 expression
Seq.fromList [1,2,3,4,5] & slicedFrom 10 .~ 0fromList [1,2,3,4,5]
valueseqOf :: Is k A_Fold => Optic' k is s a -> s -> Seq a
#

Construct a Seq from a fold.

Example1 expression
seqOf folded ["hello","world"]fromList ["hello","world"]
Example1 expression
seqOf (folded % _2) [("hello",1),("world",2),("!!!",3)]fromList [1,2,3]