Skip to content

Commit 9dd4432

Browse files
committed
Address @garyb comments.
1 parent 9571d60 commit 9dd4432

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/Data/Lens/At.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import Data.Newtype (unwrap)
1616
import Data.Lens (Lens', lens)
1717
import Data.Lens.Index (class Index)
1818

19-
-- | Use an `At` lens if you want to add
20-
-- | new elements or delete old ones:
19+
-- | `At` is a type class whose instances let you add
20+
-- | new elements or delete old ones from "container-like" types:
2121
-- |
2222
-- | ```purescript
2323
-- | whole = Map.singleton "key" "value"
@@ -30,7 +30,7 @@ import Data.Lens.Index (class Index)
3030
-- | set optic Nothing whole == Map.empty
3131
-- | ```
3232
-- |
33-
-- | If you want neither of those things, but only to view or change
33+
-- | If you don't want to add or delete, but only to view or change
3434
-- | an existing element, see `Data.Lens.Index`.
3535

3636
class Index m a b <= At m a b | m -> a, m -> b where

src/Data/Lens/Index.purs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Data.Set as S
1515
import Data.StrMap as SM
1616
import Data.Traversable (traverse)
1717

18-
-- | Use an `Index` optic on types where:
18+
-- | `Index` is a type class whose instances are optics used when:
1919
-- | 1. The focus element might not be present.
2020
-- | 2. You either cannot or do not want to add new elements or delete existing ones.
2121
-- |
@@ -27,14 +27,16 @@ import Data.Traversable (traverse)
2727
-- | set (ix 1) 8888 [0, 1, 2] == [0,8888,2]
2828
-- | ```
2929
-- |
30-
-- | Note the use of `preview` rather `view`.
30+
-- | Note the use of `preview` rather `view`. That's because the optic is
31+
-- | a `Data.Lens.Traversal` tailored to the case where there's a single element
32+
-- | of interest.
3133
-- |
3234
-- | Another common use is a `Map` that you don't want to either grow or shrink:
3335
-- |
3436
-- | ```purescript
35-
-- | (set (ix 1) 8888 $ Map.singleton 1 2) == Map.singleton 1 8888
37+
-- | (set (ix "k") "new" $ Map.singleton "k" "old") == Map.singleton "k" "new"
3638
-- |
37-
-- | (set (ix 1) 8888 $ Map.empty) == Map.empty
39+
-- | (set (ix "k") "new" $ Map.empty) == Map.empty
3840
-- | ```
3941
-- |
4042
-- | Note the second line: an attempt to `set` a missing focus element

0 commit comments

Comments
 (0)