johnynek / fastparse-cats

Cats instances for fastparse

GitHub

Build Status codecov.io Latest version

fastparse-cats

Cats instances for fastparse parsers.

This gives you a lawful Monad and Alternative for fastparse Parsers. This allows you to easily reuse generic functions from cats with fastparse.

Quick Start

fastparse-cats supports Scala 2.11, and 2.12. It supports both the JVM and JS platforms.

To use fastparse-cats in your own project, you can include this snippet in your build.sbt file:

// use this snippet for the JVM
libraryDependencies ++= List("org.bykn" %% "fastparse-cats-core" % "0.1.0")

// use this snippet for JS, or cross-building
libraryDependencies ++= List("org.bykn" %%% "fastparse-cats-core" % "0.1.0")

There is also support for fastparse-byte by using

libraryDependencies ++= List("org.bykn" %% "fastparse-cats-byte" % "0.1.0")

To use the instances, make the following imports:

// get the Monad and Alternative for string Parser
import org.bykn.fastparse_cats.StringInstances._

or

// get the Monad and Alternative for byte Parser
import org.bykn.fastparse_cats.ByteInstances._

There are also utilities to at buildParser.{ delay, suspend, pure, fromEval, fromEvalParser } to build generic parsers lazily.