softwaremill / softwaremill/quicklens

The `focus` (or `via`) path operator

Open
#24 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Scala
Stars
852
Forks
53
PR merge metrics
No merged PRs in 30d

Description

This would allow supporting arbitrary lens.

trait Lens[A, B] {
  def modify(a: A, f: B => B): A
}

object EnglishVovels extends Lens[String, Char] {
  def modify(string: String, f: Char => Char) = string map {
    case v @ ('A' | 'E' | 'I' | 'O' | 'U' | 'a' | 'e' | 'i' | 'o' | 'u') => f(v)
    case x => x
  }
}

person.modify(_.name.focus(EnglishVovels)).using(_.toUpperCase)

What do you think?

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 proposed Lens[A, B] interface and the person.modify(_.name.focus(EnglishVovels)).using(...) example in the issue. Review how the existing path operators are structured, then determine the API and behavior needed for arbitrary lenses; done means the focus or via operator works for the illustrated vowel-transformation use case with appropriate coverage.

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
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.