Safe Haskell | None |
---|---|
Language | Haskell2010 |
- _Many :: IsMany t xs a => Iso' (Many xs) (t xs a)
- _Many' :: IsMany Tagged xs a => Iso' (Many xs) a
- item :: forall x xs. UniqueMember x xs => Lens' (Many xs) x
- item' :: forall x y xs. UniqueMember x xs => Lens (Many xs) (Many (Replace x y xs)) x y
- itemL :: forall l xs x proxy. (UniqueLabelMember l xs, x ~ KindAtLabel l xs) => proxy l -> Lens' (Many xs) x
- itemL' :: forall l y xs x proxy. (UniqueLabelMember l xs, x ~ KindAtLabel l xs) => proxy l -> Lens (Many xs) (Many (Replace x y xs)) x y
- itemN :: forall n x xs proxy. MemberAt n x xs => proxy n -> Lens' (Many xs) x
- itemN' :: forall n x y xs proxy. MemberAt n x xs => proxy n -> Lens (Many xs) (Many (ReplaceIndex n y xs)) x y
- project :: forall smaller larger. (Select smaller larger, Amend smaller larger) => Lens' (Many larger) (Many smaller)
- project' :: forall smaller smaller' larger zipped. (Select smaller larger, Amend' smaller smaller' larger zipped) => Lens (Many larger) (Many (Replaces smaller smaller' larger)) (Many smaller) (Many smaller')
- projectL :: forall ls smaller larger proxy. (Select smaller larger, Amend smaller larger, smaller ~ KindsAtLabels ls larger, IsDistinct ls, UniqueLabels ls larger) => proxy ls -> Lens' (Many larger) (Many smaller)
- projectL' :: forall ls smaller smaller' larger proxy zipped. (Select smaller larger, Amend' smaller smaller' larger zipped, smaller ~ KindsAtLabels ls larger, IsDistinct ls, UniqueLabels ls larger) => proxy ls -> Lens (Many larger) (Many (Replaces smaller smaller' larger)) (Many smaller) (Many smaller')
- projectN :: forall ns smaller larger proxy. (SelectN ns smaller larger, AmendN ns smaller larger) => proxy ns -> Lens' (Many larger) (Many smaller)
- projectN' :: forall ns smaller smaller' larger proxy zipped. (SelectN ns smaller larger, AmendN' ns smaller smaller' larger zipped) => proxy ns -> Lens (Many larger) (Many (ReplacesIndex ns smaller' larger)) (Many smaller) (Many smaller')
Isomorphism
Single field
Lens for a single field
item' :: forall x y xs. UniqueMember x xs => Lens (Many xs) (Many (Replace x y xs)) x y Source #
Polymorphic version of item
itemL :: forall l xs x proxy. (UniqueLabelMember l xs, x ~ KindAtLabel l xs) => proxy l -> Lens' (Many xs) x Source #
itemL' :: forall l y xs x proxy. (UniqueLabelMember l xs, x ~ KindAtLabel l xs) => proxy l -> Lens (Many xs) (Many (Replace x y xs)) x y Source #
itemN' :: forall n x y xs proxy. MemberAt n x xs => proxy n -> Lens (Many xs) (Many (ReplaceIndex n y xs)) x y Source #
Polymorphic version of itemN
Multiple fields
Lens for multiple fields
project :: forall smaller larger. (Select smaller larger, Amend smaller larger) => Lens' (Many larger) (Many smaller) Source #
select
(view
project
) and amend
(set
project
) in Lens'
form.
project
=lens
select
amend
let x = (5 :: Int)./
False./
'X'./
Just 'O'./
nil
x^.
(project
@'[Int, Maybe Char]) `shouldBe` (5 :: Int)./
Just 'O'./
nil
(x&
(project
@'[Int, Maybe Char]).~
((6 :: Int)./
JustP
./
nil
)) `shouldBe` (6 :: Int)./
False./
'X'./
Just 'P'./
nil
project' :: forall smaller smaller' larger zipped. (Select smaller larger, Amend' smaller smaller' larger zipped) => Lens (Many larger) (Many (Replaces smaller smaller' larger)) (Many smaller) (Many smaller') Source #
Polymorphic version of project'
projectL :: forall ls smaller larger proxy. (Select smaller larger, Amend smaller larger, smaller ~ KindsAtLabels ls larger, IsDistinct ls, UniqueLabels ls larger) => proxy ls -> Lens' (Many larger) (Many smaller) Source #
selectL
(view
projectL
) and amendL
(set
projectL
) in Lens'
form.
let x = False./
Tagged @"Hi" (5 :: Int)./
Tagged @Foo False./
Tagged @Bar 'X'./
Tagged @"Bye" 'O'./
nil
x^.
(projectL
@'[Foo, Bar] Proxy) `shouldBe` Tagged @Foo False./
Tagged @Bar 'X'./
nil (x&
(projectL
@'["Hi", "Bye"] Proxy).~
(Tagged @"Hi" (6 :: Int)./
Tagged @"Bye" 'P'./
nil)) 'shouldBe
False./
Tagged @"Hi" (6 :: Int)./
Tagged @Foo False./
Tagged @Bar 'X'./
Tagged @"Bye" 'P'./
nil
projectL' :: forall ls smaller smaller' larger proxy zipped. (Select smaller larger, Amend' smaller smaller' larger zipped, smaller ~ KindsAtLabels ls larger, IsDistinct ls, UniqueLabels ls larger) => proxy ls -> Lens (Many larger) (Many (Replaces smaller smaller' larger)) (Many smaller) (Many smaller') Source #
Polymorphic version of projectL'
let x = False./
Tagged @"Hi" (5 :: Int)./
Tagged @Foo False./
Tagged @Bar 'X'./
Tagged @"Bye" 'O'./
nil
(x&
(projectL'
@'["Hi", "Bye"] Proxy).~
(True./
Tagged @"Changed" False./
nil
)) `shouldBe` False./
True./
Tagged @Foo False./
Tagged @Bar 'X'./
Tagged @"Changed" False./
nil
projectN :: forall ns smaller larger proxy. (SelectN ns smaller larger, AmendN ns smaller larger) => proxy ns -> Lens' (Many larger) (Many smaller) Source #
selectN
(view
projectN
) and amendN
(set
projectN
) in Lens'
form.
projectN
=lens
selectN
amendN
let x = (5 :: Int)./
False./
'X'./
Just 'O'./
(6 :: Int)./
Just 'A'./
nil
x^.
(projectN
@'[5, 4, 0] Proxy) `shouldBe` Just 'A'./
(6 :: Int)./
(5 ::Int)./
nil
(x&
(projectN
@'[5, 4, 0] Proxy).~
(Just 'B'./
(8 :: Int)./
(4 ::Int)./
nil)) `shouldBe` (4 :: Int)./
False./
'X'./
Just 'O'./
(8 :: Int)./
Just 'B'./
nil