Skip to content

unused local definition warning when defining focus inside a function #1484

@jtjeferreira

Description

@jtjeferreira
case class Lecturer(firstName: String, lastName: String, salary: Int)
case class Department(budget: Int, lecturers: List[Lecturer])
case class University(name: String, departments: Map[String, Department])

val uni = University("oxford", Map(
  "Computer Science" -> Department(45, List(
    Lecturer("john"  , "doe", 10),
    Lecturer("robert", "johnson", 16)
  )),
  "History" -> Department(30, List(
    Lecturer("arnold", "stones", 20)
  ))
))

import monocle.Focus
import monocle.syntax.all._

val departmentsWorks = Focus[University](_.departments)
departmentsWorks.at("History").replace(None)(uni)

def foo() = {

  //warning unused local definition
  val departments = Focus[University](_.departments)
  departments.at("History").replace(None)(uni)
}

foo()

Scastie: https://scastie.scala-lang.org/TfVaZDtKSmKGrgQuI7N3Rg

versions:
scala 3.5.2
monocle 3.3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions