keypoint keypoint - 1 year ago 86
Scala Question

what do `^^^` and `~>` mean in sbt

I'm read the sbt documentation on Commands, and wondering what do


I tried to google but nothing found, these chars are escaped by google I guess...Thanks a lot

// Demonstration of a custom parser.
// The command changes the foreground or background terminal color
// according to the input.
lazy val change = Space ~> (reset | setColor)
lazy val reset = token("reset" ^^^ "\033[0m")
lazy val color = token( Space ~> ("blue" ^^^ "4" | "green" ^^^ "2") )
lazy val select = token( "fg" ^^^ "3" | "bg" ^^^ "4" )
lazy val setColor = (select ~ color) map { case (g, c) => "\033[" + g + c + "m" }

def changeColor = Command("color")(_ => change) { (state, ansicode) =>

The full code is as example

Jan Jan
Answer Source

Those are methods on the RichParser class.


Hint. If you look for symbolic methods click the '#' on the upper left corner of the api doc page.

  • ^^^[B](value: B): Parser[B]: Apply the original Parser, but provide value as the result if it succeeds.
  • ~>[B](b: Parser[B]): Parser[B]: Produces a Parser that applies the original Parser and then applies next (in order), discarding the result of the original parser.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download