Skip to content

Instantly share code, notes, and snippets.

@julien-truffaut
Last active September 16, 2020 05:16
Show Gist options
  • Save julien-truffaut/2282c8db6c9935668433dfe0be95f689 to your computer and use it in GitHub Desktop.
Save julien-truffaut/2282c8db6c9935668433dfe0be95f689 to your computer and use it in GitHub Desktop.
Proposal for new optics names

Frieldly optics name proposals

Here are some proposal for optics names. The goal is to give a better intuition to beginners, especially people with no FP experience.

  • Setter -> Replace, Modify, Write
  • Fold -> Aggregate
  • NonEmptyFold -> Reduce
  • Getter -> Read
  • ReadOnlyOptional -> ???
  • Traversal -> ???
  • NonEmptyTraversal -> ???
  • Optional -> Find
  • Prism -> Subset, Select, Branch
  • Lens -> Field, Focus
  • Iso -> Equivalent, Equivalence, Conversion

Insipration from tofu-optics

@DavidGregory084
Copy link

Prism -> Identify?

@psisoyev
Copy link

How about:

Fold -> Aggregate
NonEmptyFold -> Reduce

@julien-truffaut
Copy link
Author

Should the optics be names or verbs? I guess we should be consistent (Reduce vs Reducer)

@ivanopagano
Copy link

Should the optics be names or verbs? I guess we should be consistent (Reduce vs Reducer)

Personally I'd go for verbs, which to me sounds simpler and more natural for the majority of cases.
Yet I can see that, as alwasys, it depends on the term used... if you choose Focus... is that a noun or a verb? View? Update?
Project might cause misunderstanding wrt Projection...

🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment