-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into update/lucuma-react-clipboard-0.46.0
- Loading branch information
Showing
12 changed files
with
128 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
version = "3.7.14" | ||
version = "3.7.15" | ||
include ".scalafmt-common.conf" | ||
runner.dialect = scala3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
modules/tests/src/test/scala/lucuma/ui/optics/OpticsSuite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (c) 2016-2023 Association of Universities for Research in Astronomy, Inc. (AURA) | ||
// For license information see LICENSE or https://opensource.org/licenses/BSD-3-Clause | ||
|
||
package lucuma.ui.optics | ||
|
||
import cats.kernel.Eq | ||
import lucuma.core.util.arb.ArbEnumerated.given | ||
import lucuma.schemas.model.ObservingMode.GmosSouthLongSlit | ||
import lucuma.schemas.model.arb.ArbObservingMode.given | ||
import monocle.law.discipline.LensTests | ||
import munit.DisciplineSuite | ||
import org.scalacheck.Arbitrary | ||
import org.scalacheck.Arbitrary.* | ||
|
||
class OpticsSuite extends DisciplineSuite: | ||
val disjointZip2 = | ||
disjointZip( | ||
GmosSouthLongSlit.grating, | ||
GmosSouthLongSlit.filter | ||
) | ||
val disjointZip3 = | ||
disjointZip( | ||
GmosSouthLongSlit.grating, | ||
GmosSouthLongSlit.filter, | ||
GmosSouthLongSlit.fpu | ||
) | ||
val disjointZip4 = | ||
disjointZip( | ||
GmosSouthLongSlit.grating, | ||
GmosSouthLongSlit.filter, | ||
GmosSouthLongSlit.fpu, | ||
GmosSouthLongSlit.explicitRoi | ||
) | ||
|
||
checkAll("disjointZip2", LensTests(disjointZip2)) | ||
checkAll("disjointZip3", LensTests(disjointZip3)) | ||
checkAll("disjointZip4", LensTests(disjointZip4)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) 2016-2023 Association of Universities for Research in Astronomy, Inc. (AURA) | ||
// For license information see LICENSE or https://opensource.org/licenses/BSD-3-Clause | ||
|
||
package lucuma.ui.optics | ||
|
||
import cats.syntax.all.* | ||
import monocle.Iso | ||
import monocle.Lens | ||
|
||
// Lenses must be disjoint (not overlap), or the result will be unsafe. | ||
// See https://github.com/optics-dev/Monocle/issues/545 | ||
def disjointZip[S, A, B](l1: Lens[S, A], l2: Lens[S, B]): Lens[S, (A, B)] = | ||
Lens((s: S) => (l1.get(s), l2.get(s)))((ab: (A, B)) => | ||
(s: S) => l2.replace(ab._2)(l1.replace(ab._1)(s)) | ||
) | ||
|
||
def disjointZip[S, A, B, C](l1: Lens[S, A], l2: Lens[S, B], l3: Lens[S, C]): Lens[S, (A, B, C)] = | ||
Lens((s: S) => (l1.get(s), l2.get(s), l3.get(s)))((abc: (A, B, C)) => | ||
(s: S) => l3.replace(abc._3)(l2.replace(abc._2)(l1.replace(abc._1)(s))) | ||
) | ||
|
||
def disjointZip[S, A, B, C, D]( | ||
l1: Lens[S, A], | ||
l2: Lens[S, B], | ||
l3: Lens[S, C], | ||
l4: Lens[S, D] | ||
): Lens[S, (A, B, C, D)] = | ||
Lens((s: S) => (l1.get(s), l2.get(s), l3.get(s), l4.get(s)))((abc: (A, B, C, D)) => | ||
(s: S) => l4.replace(abc._4)(l3.replace(abc._3)(l2.replace(abc._2)(l1.replace(abc._1)(s)))) | ||
) | ||
|
||
def disjointZip[S, A, B, C, D, E]( | ||
l1: Lens[S, A], | ||
l2: Lens[S, B], | ||
l3: Lens[S, C], | ||
l4: Lens[S, D], | ||
l5: Lens[S, E] | ||
): Lens[S, (A, B, C, D, E)] = | ||
Lens((s: S) => (l1.get(s), l2.get(s), l3.get(s), l4.get(s), l5.get(s)))((abc: (A, B, C, D, E)) => | ||
(s: S) => | ||
l5.replace(abc._5)( | ||
l4.replace(abc._4)(l3.replace(abc._3)(l2.replace(abc._2)(l1.replace(abc._1)(s)))) | ||
) | ||
) | ||
|
||
// This only behaves as a lawful lens as long as A and B are both null or both set. | ||
def unsafeDisjointOptionZip[S, A, B]( | ||
l1: Lens[S, Option[A]], | ||
l2: Lens[S, Option[B]] | ||
): Lens[S, Option[(A, B)]] = | ||
Lens((s: S) => (l1.get(s), l2.get(s)).tupled)((ab: Option[(A, B)]) => | ||
(s: S) => l2.replace(ab.map(_._2))(l1.replace(ab.map(_._1))(s)) | ||
) | ||
|
||
def optionIso[A, B](iso: Iso[A, B]): Iso[Option[A], Option[B]] = | ||
Iso[Option[A], Option[B]](_.map(iso.get))(_.map(iso.reverseGet)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
sbt.version=1.9.6 | ||
sbt.version=1.9.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1") | ||
val sbtLucumaVersion = "0.11.8" | ||
val sbtLucumaVersion = "0.11.9" | ||
addSbtPlugin("edu.gemini" % "sbt-lucuma-lib" % sbtLucumaVersion) | ||
addSbtPlugin("edu.gemini" % "sbt-lucuma-css" % sbtLucumaVersion) |