All Downloads are FREE. Search and download functionalities are using the official Maven repository.

caseapp.core.parser.MappedParser.scala Maven / Gradle / Ivy

There is a newer version: 2.0.0-M8
Show newest version
package caseapp.core.parser

import caseapp.core.{Arg, Error}

final case class MappedParser[T, D0, U](underlying: Parser.Aux[T, D0], f: T => U) extends Parser[U] {

  type D = D0

  def init: D =
    underlying.init

  def step(args: List[String], d: D): Either[(Error, List[String]), Option[(D, List[String])]] =
    underlying.step(args, d)

  def get(d: D): Either[Error, U] =
    underlying
      .get(d)
      .right
      .map(f)

  def args: Seq[Arg] =
    underlying.args

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy