From 5324fcca8d3137fd65d2f25c4e5ef9b0adb63dc9 Mon Sep 17 00:00:00 2001 From: Jamie Willis Date: Mon, 6 Feb 2023 22:57:17 +0000 Subject: [PATCH] Moved catsinstances to cats.instances, this will be more consistent: deprecated old version (#4) --- build.sbt | 12 ++++++++- .../cats}/MonoidKForParsley.scala | 5 +++- .../cats}/MonoidKForParsley.scala | 5 +++- .../{ => cats}/ApplicativeForParsley.scala | 8 +++--- .../parsley/{ => cats}/DeferForParsley.scala | 6 ++--- .../{ => cats}/FunctorFilterForParsley.scala | 4 ++- .../{ => cats}/FunctorForParsley.scala | 4 ++- .../parsley/{ => cats}/MonadForParsley.scala | 7 +++-- .../{cats.scala => cats/instances.scala} | 15 +++++------ .../main/scala/parsley/catsinstances.scala | 27 +++++++++++++++++++ .../scala/parsley/{ => cats}/CatsSuite.scala | 7 ++--- 11 files changed, 76 insertions(+), 24 deletions(-) rename parsley-cats/shared/src/main/scala-2.12/{ => parsley/cats}/MonoidKForParsley.scala (92%) rename parsley-cats/shared/src/main/scala-2.13+/{ => parsley/cats}/MonoidKForParsley.scala (91%) rename parsley-cats/shared/src/main/scala/parsley/{ => cats}/ApplicativeForParsley.scala (99%) rename parsley-cats/shared/src/main/scala/parsley/{ => cats}/DeferForParsley.scala (83%) rename parsley-cats/shared/src/main/scala/parsley/{ => cats}/FunctorFilterForParsley.scala (94%) rename parsley-cats/shared/src/main/scala/parsley/{ => cats}/FunctorForParsley.scala (91%) rename parsley-cats/shared/src/main/scala/parsley/{ => cats}/MonadForParsley.scala (94%) rename parsley-cats/shared/src/main/scala/parsley/{cats.scala => cats/instances.scala} (74%) create mode 100644 parsley-cats/shared/src/main/scala/parsley/catsinstances.scala rename parsley-cats/shared/src/test/scala/parsley/{ => cats}/CatsSuite.scala (95%) diff --git a/build.sbt b/build.sbt index c3c8393..3712737 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,5 @@ import org.scalajs.linker.interface.ESVersion +import com.typesafe.tools.mima.core._ val projectName = "parsley-cats" val Scala213 = "2.13.10" @@ -19,9 +20,18 @@ inThisBuild(List( versionScheme := Some("early-semver"), crossScalaVersions := Seq(Scala213, Scala212, Scala3), scalaVersion := Scala213, + mimaBinaryIssueFilters ++= Seq( + // Until 2.0 (these are all misreported package private members) + ProblemFilters.exclude[MissingClassProblem]("parsley.ApplicativeForParsley"), + ProblemFilters.exclude[MissingClassProblem]("parsley.DeferForParsley"), + ProblemFilters.exclude[MissingClassProblem]("parsley.FunctorFilterForParsley"), + ProblemFilters.exclude[MissingClassProblem]("parsley.FunctorForParsley"), + ProblemFilters.exclude[MissingClassProblem]("parsley.MonadForParsley"), + ProblemFilters.exclude[MissingClassProblem]("parsley.MonoidKForParsley"), + ), // CI Configuration tlCiReleaseBranches := Seq("master"), - tlSonatypeUseLegacyHost := false, // this needs to be switched off when we migrate parsley to the other server too + tlSonatypeUseLegacyHost := false, githubWorkflowJavaVersions := Seq(JavaSpec.temurin("8"), JavaSpec.temurin("11"), JavaSpec.temurin("17")), )) diff --git a/parsley-cats/shared/src/main/scala-2.12/MonoidKForParsley.scala b/parsley-cats/shared/src/main/scala-2.12/parsley/cats/MonoidKForParsley.scala similarity index 92% rename from parsley-cats/shared/src/main/scala-2.12/MonoidKForParsley.scala rename to parsley-cats/shared/src/main/scala-2.12/parsley/cats/MonoidKForParsley.scala index e502b39..6a61813 100644 --- a/parsley-cats/shared/src/main/scala-2.12/MonoidKForParsley.scala +++ b/parsley-cats/shared/src/main/scala-2.12/parsley/cats/MonoidKForParsley.scala @@ -1,7 +1,10 @@ /* SPDX-FileCopyrightText: © 2022 Parsley Cats Contributors * SPDX-License-Identifier: BSD-3-Clause */ -package parsley +package parsley.cats + +import parsley.Parsley +import parsley.combinator import cats.{Functor, MonoidK} diff --git a/parsley-cats/shared/src/main/scala-2.13+/MonoidKForParsley.scala b/parsley-cats/shared/src/main/scala-2.13+/parsley/cats/MonoidKForParsley.scala similarity index 91% rename from parsley-cats/shared/src/main/scala-2.13+/MonoidKForParsley.scala rename to parsley-cats/shared/src/main/scala-2.13+/parsley/cats/MonoidKForParsley.scala index dd5abfb..721ec96 100644 --- a/parsley-cats/shared/src/main/scala-2.13+/MonoidKForParsley.scala +++ b/parsley-cats/shared/src/main/scala-2.13+/parsley/cats/MonoidKForParsley.scala @@ -1,7 +1,10 @@ /* SPDX-FileCopyrightText: © 2022 Parsley Cats Contributors * SPDX-License-Identifier: BSD-3-Clause */ -package parsley +package parsley.cats + +import parsley.Parsley +import parsley.combinator import cats.{Functor, MonoidK} diff --git a/parsley-cats/shared/src/main/scala/parsley/ApplicativeForParsley.scala b/parsley-cats/shared/src/main/scala/parsley/cats/ApplicativeForParsley.scala similarity index 99% rename from parsley-cats/shared/src/main/scala/parsley/ApplicativeForParsley.scala rename to parsley-cats/shared/src/main/scala/parsley/cats/ApplicativeForParsley.scala index f5b6530..0cfbbe6 100644 --- a/parsley-cats/shared/src/main/scala/parsley/ApplicativeForParsley.scala +++ b/parsley-cats/shared/src/main/scala/parsley/cats/ApplicativeForParsley.scala @@ -1,11 +1,13 @@ /* SPDX-FileCopyrightText: © 2022 Parsley Cats Contributors * SPDX-License-Identifier: BSD-3-Clause */ -package parsley +package parsley.cats -import cats.Applicative +import parsley.Parsley +import parsley.combinator +import parsley.lift._ -import lift._ +import cats.Applicative private [parsley] trait ApplicativeForParsley extends Applicative[Parsley] { override def pure[A](x: A): Parsley[A] = Parsley.pure(x) diff --git a/parsley-cats/shared/src/main/scala/parsley/DeferForParsley.scala b/parsley-cats/shared/src/main/scala/parsley/cats/DeferForParsley.scala similarity index 83% rename from parsley-cats/shared/src/main/scala/parsley/DeferForParsley.scala rename to parsley-cats/shared/src/main/scala/parsley/cats/DeferForParsley.scala index 654c7ac..3e0f8dd 100644 --- a/parsley-cats/shared/src/main/scala/parsley/DeferForParsley.scala +++ b/parsley-cats/shared/src/main/scala/parsley/cats/DeferForParsley.scala @@ -1,11 +1,11 @@ /* SPDX-FileCopyrightText: © 2022 Parsley Cats Contributors * SPDX-License-Identifier: BSD-3-Clause */ -package parsley +package parsley.cats -import cats.Defer +import parsley.Parsley, Parsley.LazyParsley -import Parsley.LazyParsley +import cats.Defer private [parsley] class DeferForParsley extends Defer[Parsley] { def defer[A](p: =>parsley.Parsley[A]): parsley.Parsley[A] = ~p diff --git a/parsley-cats/shared/src/main/scala/parsley/FunctorFilterForParsley.scala b/parsley-cats/shared/src/main/scala/parsley/cats/FunctorFilterForParsley.scala similarity index 94% rename from parsley-cats/shared/src/main/scala/parsley/FunctorFilterForParsley.scala rename to parsley-cats/shared/src/main/scala/parsley/cats/FunctorFilterForParsley.scala index fff94bf..2ebf022 100644 --- a/parsley-cats/shared/src/main/scala/parsley/FunctorFilterForParsley.scala +++ b/parsley-cats/shared/src/main/scala/parsley/cats/FunctorFilterForParsley.scala @@ -1,7 +1,9 @@ /* SPDX-FileCopyrightText: © 2022 Parsley Cats Contributors * SPDX-License-Identifier: BSD-3-Clause */ -package parsley +package parsley.cats + +import parsley.Parsley import cats.{Functor, FunctorFilter} diff --git a/parsley-cats/shared/src/main/scala/parsley/FunctorForParsley.scala b/parsley-cats/shared/src/main/scala/parsley/cats/FunctorForParsley.scala similarity index 91% rename from parsley-cats/shared/src/main/scala/parsley/FunctorForParsley.scala rename to parsley-cats/shared/src/main/scala/parsley/cats/FunctorForParsley.scala index b2d34ef..0d55399 100644 --- a/parsley-cats/shared/src/main/scala/parsley/FunctorForParsley.scala +++ b/parsley-cats/shared/src/main/scala/parsley/cats/FunctorForParsley.scala @@ -1,7 +1,9 @@ /* SPDX-FileCopyrightText: © 2022 Parsley Cats Contributors * SPDX-License-Identifier: BSD-3-Clause */ -package parsley +package parsley.cats + +import parsley.Parsley import cats.Functor diff --git a/parsley-cats/shared/src/main/scala/parsley/MonadForParsley.scala b/parsley-cats/shared/src/main/scala/parsley/cats/MonadForParsley.scala similarity index 94% rename from parsley-cats/shared/src/main/scala/parsley/MonadForParsley.scala rename to parsley-cats/shared/src/main/scala/parsley/cats/MonadForParsley.scala index fe8ab4d..5a4fe5f 100644 --- a/parsley-cats/shared/src/main/scala/parsley/MonadForParsley.scala +++ b/parsley-cats/shared/src/main/scala/parsley/cats/MonadForParsley.scala @@ -1,10 +1,13 @@ /* SPDX-FileCopyrightText: © 2022 Parsley Cats Contributors * SPDX-License-Identifier: BSD-3-Clause */ -package parsley +package parsley.cats + +import parsley.Parsley +import parsley.combinator +import parsley.registers.{RegisterMaker, RegisterMethods} import cats.{Alternative, Monad} -import registers.{RegisterMaker, RegisterMethods} private [parsley] trait MonadForParsley extends Monad[Parsley] { override def flatMap[A, B](mx: Parsley[A])(f: A => Parsley[B]): Parsley[B] = mx.flatMap(f) diff --git a/parsley-cats/shared/src/main/scala/parsley/cats.scala b/parsley-cats/shared/src/main/scala/parsley/cats/instances.scala similarity index 74% rename from parsley-cats/shared/src/main/scala/parsley/cats.scala rename to parsley-cats/shared/src/main/scala/parsley/cats/instances.scala index 13baef1..20207fb 100644 --- a/parsley-cats/shared/src/main/scala/parsley/cats.scala +++ b/parsley-cats/shared/src/main/scala/parsley/cats/instances.scala @@ -1,18 +1,17 @@ -/* SPDX-FileCopyrightText: © 2022 Parsley Cats Contributors - * SPDX-License-Identifier: BSD-3-Clause - */ -package parsley +package parsley.cats + +import parsley.Parsley import cats.{Defer, FunctorFilter, Monad, MonoidK} /** Contains instances for `cats` typeclasses. * - * @since 0.1.0 + * @since 1.2.0 */ -object catsinstances { +object instances { /** Instance for the core `cats` typeclasses used with parser combinators. * - * @since 0.1.0 + * @since 1.2.0 */ implicit val monadPlusForParsley: Monad[Parsley] with MonoidK[Parsley] with FunctorFilter[Parsley] = // This must be kept in this ordering, with more generic further up @@ -23,7 +22,7 @@ object catsinstances { /** Instance for `cats` `Defer` typeclass, which allows for recursive parser generation. * - * @since 0.2.0 + * @since 1.2.0 */ implicit val deferForParsley: Defer[Parsley] = new DeferForParsley } diff --git a/parsley-cats/shared/src/main/scala/parsley/catsinstances.scala b/parsley-cats/shared/src/main/scala/parsley/catsinstances.scala new file mode 100644 index 0000000..95dca29 --- /dev/null +++ b/parsley-cats/shared/src/main/scala/parsley/catsinstances.scala @@ -0,0 +1,27 @@ +/* SPDX-FileCopyrightText: © 2022 Parsley Cats Contributors + * SPDX-License-Identifier: BSD-3-Clause + */ +package parsley + +import _root_.cats.{Defer, FunctorFilter, Monad, MonoidK} + +/** Contains instances for `cats` typeclasses. + * + * @since 0.1.0 + */ +@deprecated("This object has been renamed to `parsley.cats.instances`, this will be removed in parsley-cats 2", "1.2.0") +object catsinstances { + /** Instance for the core `cats` typeclasses used with parser combinators. + * + * @since 0.1.0 + */ + @deprecated("This has been renamed to `parsley.cats.instances.monadPlusForParsley`, this will be removed in parsley-cats 2", "1.2.0") + implicit val monadPlusForParsley: Monad[Parsley] with MonoidK[Parsley] with FunctorFilter[Parsley] = parsley.cats.instances.monadPlusForParsley + + /** Instance for `cats` `Defer` typeclass, which allows for recursive parser generation. + * + * @since 0.2.0 + */ + @deprecated("This has been renamed to `parsley.cats.instances.deferForParsley`, this will be removed in parsley-cats 2", "1.2.0") + implicit val deferForParsley: Defer[Parsley] = parsley.cats.instances.deferForParsley +} diff --git a/parsley-cats/shared/src/test/scala/parsley/CatsSuite.scala b/parsley-cats/shared/src/test/scala/parsley/cats/CatsSuite.scala similarity index 95% rename from parsley-cats/shared/src/test/scala/parsley/CatsSuite.scala rename to parsley-cats/shared/src/test/scala/parsley/cats/CatsSuite.scala index 2e7f728..17d2702 100644 --- a/parsley-cats/shared/src/test/scala/parsley/CatsSuite.scala +++ b/parsley-cats/shared/src/test/scala/parsley/cats/CatsSuite.scala @@ -1,12 +1,13 @@ -package parsley +package parsley.cats import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.matchers.should.Matchers._ import org.scalactic.source.Position -import parsley.Parsley.pure +import parsley.Parsley, Parsley.pure +import parsley.Success import parsley.character.{item, digit, char} -import parsley.catsinstances._ +import parsley.cats.instances._ import cats.laws.{MonadLaws, MonoidKLaws, FunctorFilterLaws} import cats.kernel.laws.IsEq