Skip to content

Commit

Permalink
Merge pull request #214 from OndrejSpanel/master
Browse files Browse the repository at this point in the history
Enable `at` with a derived key in Scala 3
  • Loading branch information
adamw authored Jan 23, 2024
2 parents 483bbe7 + a6f0a5c commit a1f561c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ package object quicklens {
}
}

trait QuicklensIndexedFunctor[F[_], I] {
trait QuicklensIndexedFunctor[F[_], -I] {
def at[A](fa: F[A], f: A => A, idx: I): F[A]
def atOrElse[A](fa: F[A], f: A => A, idx: I, default: => A): F[A]
def index[A](fa: F[A], f: A => A, idx: I): F[A]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,12 @@ class ModifyMapAtTest extends AnyFlatSpec with Matchers {
modify(m1)(_.at("K0").a5.name).using(duplicate)
}
}

it should "modify a map using at with a derived class" in {
class C
object D extends C
val m = Map[C, String](D -> "")
val expected = Map(D -> "x")
modify(m)(_.at(D)).setTo("x") should be(expected)
}
}

0 comments on commit a1f561c

Please sign in to comment.