optics-dev / optics-dev/Monocle
Scalafix rules for Monocle 3
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 1.7k
- Forks
- 207
- Avg merge
- 7h 59m
- Merged PRs (30d)
- 5
Description
Monocle 3 deprecates lots of methods, it would be great to use scalafix to automatically refactor the ones that have replacements. Here is a list of changes:
-
settoreplace -
setOptiontoreplaceOption
Shortcuts for popular optics
-
composeLens(at(x))toat(x) -
composePrism(some)tosome -
composeOptional(index(x))toindex(x) -
composeTraversal(each)toeach -
composeTraversal(filterIndex(predicate))tofilterIndex(predicate) -
composeLens(first)orcomposeLens(_1)toat(1) -
composeLens(second)orcomposeLens(_2)toat(2) -
composeLens(third)orcomposeLens(_3)toat(3) -
composeLens(fourth)orcomposeLens(_4)toat(4) -
composeLens(fifth)orcomposeLens(_5)toat(5) -
composeLens(sixth)orcomposeLens(_6)toat(6) -
composeOptional(headOption)toindex(0)
Overloaded compose method
-
composeFold(x)toandThen(x) -
composeGetter(x)toandThen(x) -
composeIso(x)toandThen(x) -
composeLens(x)toandThen(x) -
composePrism(x)toandThen(x) -
composeOptional(x)toandThen(x) -
composeTraversal(x)toandThen(x) -
composeSetter(x)toandThen(x)
Remove symbolic compose operators
-
^|->> xtoandThen(x) -
^|-? xtoandThen(x) -
^<-? xtoandThen(x) -
^|-> xtoandThen(x) -
^<-> xtoandThen(x)
ApplyOptics
-
applyLens(at(x))tooptics.at(x) -
applyPrism(some)tooptics.some -
applyOptional(index(x))tooptics.index(x) -
applyTraversal(each)tooptics.each -
applyTraversal(filterIndex(predicate))tooptics.filterIndex(predicate) -
applyLens(first)orapplyLens(_1)tooptics.at(1) -
applyLens(second)orapplyLens(_2)tooptics.at(2) -
applyLens(third)orapplyLens(_3)tooptics.at(3) -
applyLens(fourth)orapplyLens(_4)tooptics.at(4) -
applyLens(fifth)orapplyLens(_5)tooptics.at(5) -
applyLens(sixth)orapplyLens(_6)tooptics.at(6) -
applyOptional(headOption)tooptics.index(0) -
applyFold(x)tooptics.andThen(x) -
applyGetter(x)tooptics.andThen(x) -
applyIso(x)tooptics.andThen(x) -
applyLens(x)tooptics.andThen(x) -
applyPrism(x)tooptics.andThen(x) -
applyOptional(x)tooptics.andThen(x) -
applyTraversal(x)tooptics.andThen(x) -
applySetter(x)tooptics.andThen(x)
Reference: https://github.com/fthomas/scala-steward/blob/master/docs/scalafix-migrations.md
Originally proposed in https://github.com/optics-dev/Monocle/issues/684
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Scalafix migration reference in docs/scalafix-migrations.md and the linked Monocle issue 684. Implement rules covering the checked-list transformations for deprecated methods, shortcuts, compose operators, and ApplyOptics, then verify that each listed migration is handled safely.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100