vec-lens-0.3: Vec: length-indexed (sized) list: lens support

Safe HaskellNone
LanguageHaskell2010

Data.Vec.Pull.Lens

Contents

Synopsis

Indexing

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

Index lens.

>>> ('a' L.::: 'b' L.::: 'c' L.::: L.VNil) ^. L._Pull . ix (FS FZ)
'b'
>>> ('a' L.::: 'b' L.::: 'c' L.::: L.VNil) & L._Pull . ix (FS FZ) .~ 'x'
'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'.

>>> ('a' L.::: 'b' L.::: 'c' L.::: L.VNil) ^. L._Pull . _head
'a'
>>> ('a' L.::: 'b' L.::: 'c' L.::: L.VNil) & L._Pull . _head .~ 'x'
'x' ::: 'b' ::: 'c' ::: VNil

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

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

Conversions

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

Prism from list.

Orphan instances

FunctorWithIndex (Fin n) (Vec n) Source # 
Instance details

Methods

imap :: (Fin n -> a -> b) -> Vec n a -> Vec n b #

imapped :: IndexedSetter (Fin n) (Vec n a) (Vec n b) a b #

SNatI n => FoldableWithIndex (Fin n) (Vec n) Source # 
Instance details

Methods

ifoldMap :: Monoid m => (Fin n -> a -> m) -> Vec n a -> m #

ifolded :: IndexedFold (Fin n) (Vec n a) a #

ifoldr :: (Fin n -> a -> b -> b) -> b -> Vec n a -> b #

ifoldl :: (Fin n -> b -> a -> b) -> b -> Vec n a -> b #

ifoldr' :: (Fin n -> a -> b -> b) -> b -> Vec n a -> b #

ifoldl' :: (Fin n -> b -> a -> b) -> b -> Vec n a -> b #