Skip to content

Commit

Permalink
Moved catsinstances to cats.instances, this will be more consistent: …
Browse files Browse the repository at this point in the history
…deprecated old version (#4)
  • Loading branch information
j-mie6 authored Feb 6, 2023
1 parent 2e679dc commit 5324fcc
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 24 deletions.
12 changes: 11 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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")),
))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/* SPDX-FileCopyrightText: © 2022 Parsley Cats Contributors <https://github.com/j-mie6/parsley-cats/graphs/contributors>
* SPDX-License-Identifier: BSD-3-Clause
*/
package parsley
package parsley.cats

import parsley.Parsley
import parsley.combinator

import cats.{Functor, MonoidK}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
/* SPDX-FileCopyrightText: © 2022 Parsley Cats Contributors <https://github.com/j-mie6/parsley-cats/graphs/contributors>
* SPDX-License-Identifier: BSD-3-Clause
*/
package parsley
package parsley.cats

import parsley.Parsley
import parsley.combinator

import cats.{Functor, MonoidK}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/* SPDX-FileCopyrightText: © 2022 Parsley Cats Contributors <https://github.com/j-mie6/parsley-cats/graphs/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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* SPDX-FileCopyrightText: © 2022 Parsley Cats Contributors <https://github.com/j-mie6/parsley-cats/graphs/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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* SPDX-FileCopyrightText: © 2022 Parsley Cats Contributors <https://github.com/j-mie6/parsley-cats/graphs/contributors>
* SPDX-License-Identifier: BSD-3-Clause
*/
package parsley
package parsley.cats

import parsley.Parsley

import cats.{Functor, FunctorFilter}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* SPDX-FileCopyrightText: © 2022 Parsley Cats Contributors <https://github.com/j-mie6/parsley-cats/graphs/contributors>
* SPDX-License-Identifier: BSD-3-Clause
*/
package parsley
package parsley.cats

import parsley.Parsley

import cats.Functor

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/* SPDX-FileCopyrightText: © 2022 Parsley Cats Contributors <https://github.com/j-mie6/parsley-cats/graphs/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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
/* SPDX-FileCopyrightText: © 2022 Parsley Cats Contributors <https://github.com/j-mie6/parsley-cats/graphs/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
Expand All @@ -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
}
27 changes: 27 additions & 0 deletions parsley-cats/shared/src/main/scala/parsley/catsinstances.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* SPDX-FileCopyrightText: © 2022 Parsley Cats Contributors <https://github.com/j-mie6/parsley-cats/graphs/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
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 5324fcc

Please sign in to comment.