Skip to content

Commit

Permalink
Deprecate Possible (#992)
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-truffaut authored Dec 17, 2020
1 parent 6613da3 commit 71cb474
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ lazy val buildSettings = Seq(
"-Wconf:msg=class Field4 in package function is deprecated:i",
"-Wconf:msg=class Field5 in package function is deprecated:i",
"-Wconf:msg=class Field6 in package function is deprecated:i",
"-Wconf:msg=class Possible in package function is deprecated:i",
"-Wconf:msg=class Reverse in package function is deprecated:i",
"-Wconf:msg=class Snoc in package function is deprecated:i",
"-Wconf:msg=class Snoc1 in package function is deprecated:i",
Expand Down
2 changes: 2 additions & 0 deletions core/shared/src/main/scala/monocle/function/Possible.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import cats.data.Validated
* @tparam S source of the [[Optional]]
* @tparam A target of the [[Optional]], `A` is supposed to be unique for a given `S`
*/
@deprecated("no replacement", since = "3.0.0-M1")
abstract class Possible[S, A] extends Serializable {
def possible: Optional[S, A]
}

trait PossibleFunctions {
@deprecated("no replacement", since = "3.0.0-M1")
def possible[S, A](implicit ev: Possible[S, A]): Optional[S, A] = ev.possible
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.typelevel.discipline.Laws

import cats.Eq

@deprecated("no replacement", since = "3.0.0-M1")
object PossibleTests extends Laws {
def apply[S: Eq: Arbitrary, A: Eq: Arbitrary](implicit
evPossible: Possible[S, A],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import monocle.MonocleSuite
import monocle.law.discipline.function.PossibleTests
import Possible.optionPossible

import scala.annotation.nowarn

@nowarn
class PossibleSpec extends MonocleSuite {
implicit def optionEitherPossible[A]: Possible[Either[Unit, A], A] =
Possible.fromIso(Iso[Either[Unit, A], Option[A]] {
Expand Down
4 changes: 3 additions & 1 deletion test/shared/src/test/scala/monocle/std/EitherSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import monocle.MonocleSuite
import monocle.law.discipline.PrismTests
import monocle.law.discipline.function.{EachTests, PossibleTests}

import scala.annotation.nowarn

class EitherSpec extends MonocleSuite {
checkAll("either left", PrismTests(stdLeft[String, Int]))
checkAll("either right", PrismTests(stdRight[String, String]))
checkAll("each Either", EachTests[Either[Unit, Int], Int])
checkAll("possible Either", PossibleTests[Either[Unit, Int], Int])
checkAll("possible Either", PossibleTests[Either[Unit, Int], Int]): @nowarn
}
2 changes: 1 addition & 1 deletion test/shared/src/test/scala/monocle/std/OptionSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class OptionSpec extends MonocleSuite {
checkAll("pOptionToDisjunction", IsoTests(pOptionToDisjunction[Int, Int]))

checkAll("each Option", EachTests[Option[Int], Int])
checkAll("possible Option", PossibleTests[Option[Int], Int])
checkAll("possible Option", PossibleTests[Option[Int], Int]): @nowarn
checkAll("empty Option", EmptyTests[Option[Int]]): @nowarn

case class IntNoZero(value: Int)
Expand Down
5 changes: 3 additions & 2 deletions test/shared/src/test/scala/monocle/std/TrySpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import monocle.law.discipline.PrismTests
import monocle.law.discipline.function.{EachTests, PossibleTests}

import scala.util.Try

import cats.Eq

import scala.annotation.nowarn

class TrySpec extends MonocleSuite {
implicit private def tryEqual[A]: Eq[Try[A]] =
Eq.fromUniversalEquals[Try[A]]
Expand All @@ -18,5 +19,5 @@ class TrySpec extends MonocleSuite {
checkAll("trySuccess", PrismTests(monocle.std.utilTry.trySuccess[Int]))
checkAll("tryFailure", PrismTests(monocle.std.utilTry.tryFailure[Int]))
checkAll("each Try", EachTests[Try[Int], Int])
checkAll("possible Try", PossibleTests[Try[Int], Int])
checkAll("possible Try", PossibleTests[Try[Int], Int]): @nowarn
}
4 changes: 3 additions & 1 deletion test/shared/src/test/scala/monocle/std/ValidatedSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import monocle.law.discipline.{IsoTests, PrismTests}
import monocle.law.discipline.function.{EachTests, PossibleTests}
import cats.data.Validated

import scala.annotation.nowarn

class ValidatedSpec extends MonocleSuite {
import cats.laws.discipline.arbitrary._

Expand All @@ -15,5 +17,5 @@ class ValidatedSpec extends MonocleSuite {
checkAll("success", PrismTests(monocle.std.validated.success[String, Int]))
checkAll("failure", PrismTests(monocle.std.validated.failure[String, Int]))
checkAll("each Validated", EachTests[Validated[Unit, Int], Int])
checkAll("possible Validated", PossibleTests[Validated[Unit, Int], Int])
checkAll("possible Validated", PossibleTests[Validated[Unit, Int], Int]): @nowarn
}

0 comments on commit 71cb474

Please sign in to comment.