Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- ix :: forall n f a. (SNatI n, Functor f) => Fin n -> LensLike' f (Vec n a) a
- _Cons :: Iso (Vec ('S n) a) (Vec ('S n) b) (a, Vec n a) (b, Vec n b)
- _head :: Lens' (Vec ('S n) a) a
- _tail :: Lens' (Vec ('S n) a) (Vec n a)
- _Pull :: SNatI n => Iso (Vec n a) (Vec n b) (Vec n a) (Vec n b)
- _Vec :: SNatI n => Prism' [a] (Vec n a)
Indexing
ix :: forall n f a. (SNatI n, Functor f) => Fin n -> LensLike' f (Vec n a) a Source #
Index lens.
>>>
('a' ::: 'b' ::: 'c' ::: VNil) ^. ix (FS FZ)
'b'
>>>
('a' ::: 'b' ::: 'c' ::: VNil) & 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 ReifiedPrism
.
In fact,
cannot have an instance of Vec
n aCons
as types don't match.
_head :: Lens' (Vec ('S n) a) a Source #
Head lens. Note: lens
_head
is a Traversal'
.
>>>
('a' ::: 'b' ::: 'c' ::: VNil) ^. _head
'a'
>>>
('a' ::: 'b' ::: 'c' ::: VNil) & _head .~ 'x'
'x' ::: 'b' ::: 'c' ::: VNil