j-mie6 / parsley-cats   1.3.0

BSD 3-clause "New" or "Revised" License GitHub

Typeclass instances for `parsley` to make it compatible with `cats`

Scala versions: 3.x 2.13 2.12
Scala.js versions: 1.x
Scala Native versions: 0.4

Parsley Cats GitHub Workflow Status parsley-cats Scala version support GitHub license GitHub commits since latest release (by SemVer) Code of Conduct Badge-Scaladoc Typelevel Affiliate Project Cats friendly

What is parsley-cats?

The parsley-cats library exposes cats instances for MonoidK[Parsley], Monad[Parsley], and FunctorFilter[Parsley] as well as Defer[Parsley]. Care should still be taken to not define truly recursive parsers using the cats API (although monadic parser with flatMap may be generally recursive, just slow). In particular, make use of Defer[Parsley].fix to handle recursion, or plain lazy val based construction (as in regular parsley use).

How do I use it? parsley-cats Scala version support parsley-cats Scala version support parsley-cats Scala version support

Parsley cats is distributed on Maven Central, and can be added to your project via:

libraryDependencies += "com.github.j-mie6" %% "parsley-cats" % "1.3.0"

it requires parsley and cats-core to also be dependencies of your project. The current version matrix for parsley-cats:

parsley-cats version parsley version cats-core version
0.1.x >= 4 && < 5 >= 2.8 && < 3
0.2.x >= 4 && < 5 >= 2.8 && < 3
1.0.x >= 4 && < 5 >= 2.8 && < 3
1.1.x >= 4 && < 5 >= 2.8 && < 3
1.2.x >= 4 && < 5 >= 2.8 && < 3
1.3.x >= 4.5 && < 5 >= 2.8 && < 3

To make use of your favourite cats syntax, you'll want the following imports:

import cats.syntax.all._
import parsley.cats.instances._

Documentation can be found here

What is parsley?

Parsley is a fast, modern, parser combinator library based loosely on Haskell's parsec and megaparsec. For examples, see its repo and wiki!

Known Incompatiblities

The following are known conflicts between the syntactic extensions of cats and the base combinators on parsley. This only needs to be considered when writing concrete values of type Parsley[A]: combinators that rely on generic instances over a type F will use the cats version of the conflicting combinators.

  • The SemigroupK syntax for combine of <+> is incompatible with parsley, which defines <+> to be a combine combinator returning Parsley[Either[A, B]]: the cats combinator <+> is known in parsley as <|>, orElse, or |.