@@ -86,15 +86,23 @@ type Lens s t a b = forall p. Strong p => Optic p s t a b
86
86
87
87
type Lens' s a = Lens s s a a
88
88
89
- -- | A prism.
89
+ -- | Prisms are used for sum types like `Maybe` and `Either`.
90
+ -- | The specialized type `Prism' s a` means that the type `s` might contain a value of type `a`.
90
91
type Prism s t a b = forall p . Choice p => Optic p s t a b
91
92
type Prism' s a = Prism s s a a
92
93
93
- -- | A generalized isomorphism.
94
+ -- | A generalized isomorphism.
95
+ -- | Isos are the most constrained optic, simply enabling you to transform back and forth between two types without losing information.
96
+ -- | The specialized type `Iso' s a` means that `s` and `a` are isomorphic – the two types represent the same information.
97
+ -- | They’re especially useful when you need to unwrap a newtype or transform an array to a list or otherwise convert between types.
98
+ -- | This optic is also useful for backward compatibility without boilerplate.
94
99
type Iso s t a b = forall p . Profunctor p => Optic p s t a b
95
100
type Iso' s a = Iso s s a a
96
101
97
- -- | A traversal.
102
+ -- | The specialized type `Traversal s a` means that the type `s` contains zero, one, or many values of type `a`.
103
+ -- | They're especially useful when working with collections like arrays, maps, and any other member of the `Traversable` type class.
104
+ -- | They are also a more general form of lenses and prisms.
105
+ -- | Traversals which focus on at most one element (like lenses, prisms, and their composition) are called affine traversals.
98
106
type Traversal s t a b = forall p . Wander p => Optic p s t a b
99
107
type Traversal' s a = Traversal s s a a
100
108
@@ -153,7 +161,6 @@ type Grate' s a = Grate s s a a
153
161
type AGrate s t a b = Optic (Grating a b ) s t a b
154
162
type AGrate' s a = AGrate s s a a
155
163
156
- -- | A getter.
157
164
type Getter :: Type -> Type -> Type -> Type -> Type
158
165
type Getter s t a b = forall r . Fold r s t a b
159
166
@@ -164,44 +171,36 @@ type AGetter s t a b = Fold a s t a b
164
171
165
172
type AGetter' s a = AGetter s s a a
166
173
167
- -- | A setter.
168
174
type Setter s t a b = Optic Function s t a b
169
175
type Setter' s a = Setter s s a a
170
176
171
- -- | A review.
172
177
type Review :: Type -> Type -> Type -> Type -> Type
173
178
type Review s t a b = Optic Tagged s t a b
174
179
175
180
type Review' s a = Review s s a a
176
181
177
- -- | A fold.
178
182
type Fold :: Type -> Type -> Type -> Type -> Type -> Type
179
183
type Fold r s t a b = Optic (Forget r ) s t a b
180
184
181
185
type Fold' r s a = Fold r s s a a
182
186
183
- -- | An indexed optic.
184
187
type IndexedOptic :: (Type -> Type -> Type ) -> Type -> Type -> Type -> Type -> Type -> Type
185
188
type IndexedOptic p i s t a b = Indexed p i a b -> p s t
186
189
187
190
type IndexedOptic' p i s a = IndexedOptic p i s s a a
188
191
189
- -- | An indexed traversal.
190
192
type IndexedTraversal i s t a b = forall p . Wander p => IndexedOptic p i s t a b
191
193
type IndexedTraversal' i s a = IndexedTraversal i s s a a
192
194
193
- -- | An indexed fold.
194
195
type IndexedFold :: Type -> Type -> Type -> Type -> Type -> Type -> Type
195
196
type IndexedFold r i s t a b = IndexedOptic (Forget r ) i s t a b
196
197
197
198
type IndexedFold' r i s a = IndexedFold r i s s a a
198
199
199
- -- | An indexed getter.
200
200
type IndexedGetter :: Type -> Type -> Type -> Type -> Type -> Type
201
201
type IndexedGetter i s t a b = IndexedFold a i s t a b
202
202
203
203
type IndexedGetter' i s a = IndexedGetter i s s a a
204
204
205
- -- | An indexed setter.
206
205
type IndexedSetter i s t a b = IndexedOptic Function i s t a b
207
206
type IndexedSetter' i s a = IndexedSetter i s s a a
0 commit comments