optics-dev / optics-dev/Monocle

Is it possible to make @Lenses ignore some fields?

Open
#1,411 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
Scala
Stars
1.7k
Forks
207
Avg merge
7h 59m
Merged PRs (30d)
5

Description

Suppose I have the following case class (I'm using Scala 2.13):

case class Foo(
  a: Int,
  b: Int,
  ...,
  z: Int,
  noLens: Int
)

Is there any way to use @Lenses to create lenses for all fields except noLens? I tried using private val or multiple parameter lists, but both cases resulted in a compilation error. I know I can manually create all the other lenses, but that's very verbose.

Thanks

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 at the @Lenses annotation implementation for Scala 2.13 and trace how fields in a case class are selected. Review the existing @Lenses behavior and determine whether excluding noLens can be specified without breaking generated lenses; done means a clearly defined, compiling behavior or a documented limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.