optics-dev / optics-dev/Monocle

Scalafix rules for Monocle 3

Open
#1,001 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

3.x
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:

  • set to replace
  • setOption to replaceOption
Shortcuts for popular optics
  • composeLens(at(x)) to at(x)
  • composePrism(some) to some
  • composeOptional(index(x)) to index(x)
  • composeTraversal(each) to each
  • composeTraversal(filterIndex(predicate)) to filterIndex(predicate)
  • composeLens(first) or composeLens(_1) to at(1)
  • composeLens(second) or composeLens(_2) to at(2)
  • composeLens(third) or composeLens(_3) to at(3)
  • composeLens(fourth) or composeLens(_4) to at(4)
  • composeLens(fifth) or composeLens(_5) to at(5)
  • composeLens(sixth) or composeLens(_6) to at(6)
  • composeOptional(headOption) to index(0)
Overloaded compose method
  • composeFold(x) to andThen(x)
  • composeGetter(x) to andThen(x)
  • composeIso(x) to andThen(x)
  • composeLens(x) to andThen(x)
  • composePrism(x) to andThen(x)
  • composeOptional(x) to andThen(x)
  • composeTraversal(x) to andThen(x)
  • composeSetter(x) to andThen(x)
Remove symbolic compose operators
  • ^|->> x to andThen(x)
  • ^|-? x to andThen(x)
  • ^<-? x to andThen(x)
  • ^|-> x to andThen(x)
  • ^<-> x to andThen(x)
ApplyOptics
  • applyLens(at(x)) to optics.at(x)
  • applyPrism(some) to optics.some
  • applyOptional(index(x)) to optics.index(x)
  • applyTraversal(each) to optics.each
  • applyTraversal(filterIndex(predicate)) to optics.filterIndex(predicate)
  • applyLens(first) or applyLens(_1) to optics.at(1)
  • applyLens(second) or applyLens(_2) to optics.at(2)
  • applyLens(third) or applyLens(_3) to optics.at(3)
  • applyLens(fourth) or applyLens(_4) to optics.at(4)
  • applyLens(fifth) or applyLens(_5) to optics.at(5)
  • applyLens(sixth) or applyLens(_6) to optics.at(6)
  • applyOptional(headOption) to optics.index(0)
  • applyFold(x) to optics.andThen(x)
  • applyGetter(x) to optics.andThen(x)
  • applyIso(x) to optics.andThen(x)
  • applyLens(x) to optics.andThen(x)
  • applyPrism(x) to optics.andThen(x)
  • applyOptional(x) to optics.andThen(x)
  • applyTraversal(x) to optics.andThen(x)
  • applySetter(x) to optics.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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.