Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/j-mie6/parsley-cats
Typeclass instances for `parsley` to make it compatible with `cats`
https://github.com/j-mie6/parsley-cats
cats parser parser-combinators scala
Last synced: 28 days ago
JSON representation
Typeclass instances for `parsley` to make it compatible with `cats`
- Host: GitHub
- URL: https://github.com/j-mie6/parsley-cats
- Owner: j-mie6
- License: bsd-3-clause
- Created: 2022-07-03T09:27:28.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-09-06T16:17:34.000Z (4 months ago)
- Last Synced: 2024-09-06T19:31:27.233Z (4 months ago)
- Topics: cats, parser, parser-combinators, scala
- Language: Scala
- Homepage:
- Size: 108 KB
- Stars: 10
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Parsley Cats ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/j-mie6/parsley-cats/ci.yml?branch=master) [![parsley-cats Scala version support](https://index.scala-lang.org/j-mie6/parsley-cats/parsley-cats/latest.svg)](https://index.scala-lang.org/j-mie6/parsley-cats/parsley-cats) [![GitHub license](https://img.shields.io/github/license/j-mie6/parsley-cats.svg)](https://github.com/j-mie6/parsley-cats/blob/master/LICENSE) ![GitHub commits since latest release (by SemVer)](https://img.shields.io/github/commits-since/j-mie6/parsley-cats/latest) ![Code of Conduct](https://img.shields.io/badge/Code%20of%20Conduct-Scala-blue.svg) [![Badge-Scaladoc]][Link-Scaladoc] ![Typelevel Affiliate Project](https://img.shields.io/badge/typelevel-affiliate%20project-FFB4B5.svg)
## 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](https://index.scala-lang.org/j-mie6/parsley-cats/parsley-cats/latest-by-scala-version.svg?platform=jvm)](https://index.scala-lang.org/j-mie6/parsley-cats/parsley-cats) [![parsley-cats Scala version support](https://index.scala-lang.org/j-mie6/parsley-cats/parsley-cats/latest-by-scala-version.svg?platform=sjs1)](https://index.scala-lang.org/j-mie6/parsley-cats/parsley-cats) [![parsley-cats Scala version support](https://index.scala-lang.org/j-mie6/parsley-cats/parsley-cats/latest-by-scala-version.svg?platform=native0.4)](https://index.scala-lang.org/j-mie6/parsley-cats/parsley-cats)
Parsley cats is distributed on Maven Central, and can be added to your project via:
```scala
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:
```scala
import cats.syntax.all._
import parsley.cats.instances._
```Documentation can be found [**here**][Link-Scaladoc]
## What is `parsley`?
[Parsley](https://github.com/j-mie6/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 `|`.[Link-Scaladoc]: https://javadoc.io/doc/com.github.j-mie6/parsley-cats_2.13/latest/index.html
[Badge-Scaladoc]: https://img.shields.io/badge/documentation-available-green