vec-optics-0.4: Vec: length-indexed (sized) list: optics support
Safe HaskellNone
LanguageHaskell2010

Data.Vec.Lazy.Optics

Synopsis

Indexing

ix :: Fin n -> Lens' (Vec n a) a Source #

Index lens.

>>> view (ix (FS FZ)) ('a' ::: 'b' ::: 'c' ::: VNil)
'b'
>>> set (ix (FS FZ)) 'x' ('a' ::: 'b' ::: 'c' ::: VNil)
'a' ::: 'x' ::: 'c' ::: VNil

_Cons :: Iso (Vec ('S n) a) (Vec ('S n) b) (a, Vec n a) (b, Vec n b) Source #

Match on non-empty Vec.

Note: lens _Cons is a Prism. In fact, Vec n a cannot have an instance of Cons as types don't match.

_head :: Lens' (Vec ('S n) a) a Source #

Head lens. Note: lens _head is a Traversal'.

>>> view _head ('a' ::: 'b' ::: 'c' ::: VNil)
'a'
>>> set _head 'x' ('a' ::: 'b' ::: 'c' ::: VNil)
'x' ::: 'b' ::: 'c' ::: VNil

_tail :: Lens' (Vec ('S n) a) (Vec n a) Source #

Tail lens.

Conversions

_Pull :: SNatI n => Iso (Vec n a) (Vec n b) (Vec n a) (Vec n b) Source #

An Iso from toPull and fromPull.

_Vec :: SNatI n => Prism' [a] (Vec n a) Source #

Prism from list.

>>> preview _Vec "foo" :: Maybe (Vec N.Nat3 Char)
Just ('f' ::: 'o' ::: 'o' ::: VNil)
>>> preview _Vec "foo" :: Maybe (Vec N.Nat2 Char)
Nothing
>>> review _Vec (True ::: False ::: VNil)
[True,False]

Orphan instances

Each (Fin n) (Vec n a) (Vec n b) a b Source # 
Instance details

Methods

each :: IxTraversal (Fin n) (Vec n a) (Vec n b) a b #

Ixed (Vec n a) Source #

Vec doesn't have At instance, as we cannot remove value from Vec. See ix in Data.Vec.Lazy module for an Optics (not Traversal).

Instance details

Associated Types

type IxKind (Vec n a) #

Methods

ix :: Index (Vec n a) -> Optic' (IxKind (Vec n a)) NoIx (Vec n a) (IxValue (Vec n a)) #

Field1 (Vec ('S n) a) (Vec ('S n) a) a a Source # 
Instance details

Methods

_1 :: Lens (Vec ('S n) a) (Vec ('S n) a) a a #

Field2 (Vec ('S ('S n)) a) (Vec ('S ('S n)) a) a a Source # 
Instance details

Methods

_2 :: Lens (Vec ('S ('S n)) a) (Vec ('S ('S n)) a) a a #

Field3 (Vec ('S ('S ('S n))) a) (Vec ('S ('S ('S n))) a) a a Source # 
Instance details

Methods

_3 :: Lens (Vec ('S ('S ('S n))) a) (Vec ('S ('S ('S n))) a) a a #

Field4 (Vec ('S ('S ('S ('S n)))) a) (Vec ('S ('S ('S ('S n)))) a) a a Source # 
Instance details

Methods

_4 :: Lens (Vec ('S ('S ('S ('S n)))) a) (Vec ('S ('S ('S ('S n)))) a) a a #

Field5 (Vec ('S ('S ('S ('S ('S n))))) a) (Vec ('S ('S ('S ('S ('S n))))) a) a a Source # 
Instance details

Methods

_5 :: Lens (Vec ('S ('S ('S ('S ('S n))))) a) (Vec ('S ('S ('S ('S ('S n))))) a) a a #

Field6 (Vec ('S ('S ('S ('S ('S ('S n)))))) a) (Vec ('S ('S ('S ('S ('S ('S n)))))) a) a a Source # 
Instance details

Methods

_6 :: Lens (Vec ('S ('S ('S ('S ('S ('S n)))))) a) (Vec ('S ('S ('S ('S ('S ('S n)))))) a) a a #

Field7 (Vec ('S ('S ('S ('S ('S ('S ('S n))))))) a) (Vec ('S ('S ('S ('S ('S ('S ('S n))))))) a) a a Source # 
Instance details

Methods

_7 :: Lens (Vec ('S ('S ('S ('S ('S ('S ('S n))))))) a) (Vec ('S ('S ('S ('S ('S ('S ('S n))))))) a) a a #

Field8 (Vec ('S ('S ('S ('S ('S ('S ('S ('S n)))))))) a) (Vec ('S ('S ('S ('S ('S ('S ('S ('S n)))))))) a) a a Source # 
Instance details

Methods

_8 :: Lens (Vec ('S ('S ('S ('S ('S ('S ('S ('S n)))))))) a) (Vec ('S ('S ('S ('S ('S ('S ('S ('S n)))))))) a) a a #

Field9 (Vec ('S ('S ('S ('S ('S ('S ('S ('S ('S n))))))))) a) (Vec ('S ('S ('S ('S ('S ('S ('S ('S ('S n))))))))) a) a a Source # 
Instance details

Methods

_9 :: Lens (Vec ('S ('S ('S ('S ('S ('S ('S ('S ('S n))))))))) a) (Vec ('S ('S ('S ('S ('S ('S ('S ('S ('S n))))))))) a) a a #