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).
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
Parsley is a fast, modern, parser combinator library based loosely on Haskell's parsec
and
megaparsec
. For examples, see its repo and wiki!
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 forcombine
of<+>
is incompatible withparsley
, which defines<+>
to be a combine combinator returningParsley[Either[A, B]]
: thecats
combinator<+>
is known inparsley
as<|>
,orElse
, or|
.