Skip to content

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

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions