项目作者: tulz-app

项目描述 :
A syntax extension for cats-parse for product tuple concatenation.
高级语言: Scala
项目地址: git://github.com/tulz-app/tuplez-parse.git
创建时间: 2021-05-09T14:52:28Z
项目社区:https://github.com/tulz-app/tuplez-parse

开源协议:MIT License

下载


Maven Central

tuplez-parse

A syntax extension for cats-parse for product tuple concatenation.

Based on the tuplez library.

Published for Scala 2.12, 2.13 and 3.3.3, JVM and Scala.js 1.16.0+.

Adding to a project

  1. "app.tulz" %%% "tuplez-parse" % "0.4.0"

Additionally, one of the following dependencies is required (see tuplez).

This is required because this library depends on tuplez-full-light but with the Provided modifier,
so it will not be transitively added to your project.

  1. // tupleN + scalar, scalar + tupleN, tupleN + tupleM, up to Tuple22
  2. "app.tulz" %%% "tuplez-full" % "0.4.0"
  3. // or
  4. // tupleN + scalar, scalar + tupleN, tupleN + tupleM, up to Tuple10
  5. "app.tulz" %%% "tuplez-full-light" % "0.4.0"
  6. // or
  7. // tupleN + scalar, up to Tuple22
  8. "app.tulz" %%% "tuplez-basic" % "0.4.0"
  9. // or
  10. // tupleN + scalar, up to Tuple10
  11. "app.tulz" %%% "tuplez-basic-light" % "0.4.0"

Extension method

Currently, the only extension method provided is ~~. It calls the underlying ~ method, and concatenates the resulting
tuple using the implicits from the tuplez library.

Usage

  1. import cats.parse.{Parser => P}
  2. import app.tulz.tuplez.parse._
  3. // no concatenation
  4. P.char('0') ~ P.char('1') // Parser[(Unit, Unit)]
  5. // with concatenation
  6. P.char('0') ~~ P.char('1') // Parser[Unit]
  7. // no concatenation
  8. P.charIn('0') ~ P.charIn('1') ~ P.charIn('2') // Parser[((Char, Char), Char)]
  9. // with concatenation
  10. P.charIn('0') ~~ P.charIn('1') ~~ P.charIn('2') // Parser[(Char, Char, Char)]
  11. // no concatenation
  12. P.charIn('1') ~ P.char('/') ~ P.charIn('2') // Parser[((Char, Unit), Char)]
  13. // with concatenation
  14. P.charIn('1') ~~ P.char('/') ~~ P.charIn('2') // Parser[(Char, Char)]

Author

Iurii Malchenko – @yurique / keybase.io/yurique

License

tuplez-parse is provided under the MIT license.