Methods
_1 :: Lens s t a bGives access to the 1st field of a tuple (up to 5-tuples).
Getting the 1st component:
Example1 expression (1,2,3,4,5) ^. _11
Setting the 1st component:
Example1 expression (1,2,3) & _1 .~ 10(10,2,3)
Note that this lens is lazy, and can set fields even of undefined:
Example1 expression set _1 10 undefined :: (Int, Int)(10,*** Exception: Prelude.undefined
This is done to avoid violating a lens law stating that you can get back what you put:
Example1 expression view _1 . set _1 10 $ (undefined :: (Int, Int))10
The implementation (for 2-tuples) is:
_1 f t = (,) <$> f (fst t) <*> pure (snd t)or, alternatively,
_1 f ~(a,b) = (\a' -> (a',b)) <$> f a(where
~means a lazy pattern).
Instances8Field1, …
Field1 (a, b) (a', b) a a'Defined in microlens-0.5.0.0 · Lens.Micro.FieldNField1 (a, b, c) (a', b, c) a a'Defined in microlens-0.5.0.0 · Lens.Micro.FieldNField1 (a, b, c, d) (a', b, c, d) a a'Defined in microlens-0.5.0.0 · Lens.Micro.FieldNField1 (a, b, c, d, e) (a', b, c, d, e) a a'Defined in microlens-0.5.0.0 · Lens.Micro.FieldNField1 (a, b, c, d, e, f) (a', b, c, d, e, f) a a'Defined in microlens-0.5.0.0 · Lens.Micro.FieldNField1 (a, b, c, d, e, f, g) (a', b, c, d, e, f, g) a a'Defined in microlens-0.5.0.0 · Lens.Micro.FieldNField1 (a, b, c, d, e, f, g, h) (a', b, c, d, e, f, g, h) a a'Defined in microlens-0.5.0.0 · Lens.Micro.FieldNField1 (a, b, c, d, e, f, g, h, i) (a', b, c, d, e, f, g, h, i) a a'Defined in microlens-0.5.0.0 · Lens.Micro.FieldN