well-typed / optics

Optics as an abstract interface
376 stars 24 forks source link

Improve documentation on what names are generated by the various functions #493

Open yav opened 1 year ago

yav commented 1 year ago

Many of the naming methods do not describe what they do, so the only way to know is to try look through the source code, or do experimentation trying to guess what they might have done, which is not a great experience.

Here is an example of one that has good documentation:

A FieldNamer that strips the off of the field name, lowercases the name, and skips the field if it doesn't start with an ''.

Here is an example of one that has bad documentation:

A FieldNamer for abbreviatedFields.

This second style would make sense, if abbreviatedFields had some documentation but that's not the case. In any case, documenting that the namer is used by some other function doesn't seem nearly as useful as saying what it does.

Similarly, the functions that generate prisms, makePrismLabels, and makePrisms should say how the names/labels of the prisms are derived from the name of the constructor. It would also be handy of these were configurable, in a style similar to what happens with fields.