ap
This module contains ap1
through ap22
, which allow for the application of a parser returning a function of arity N
to N
parsers.
The combinators contained in this module all sequence a number of parsers together, but are capable of combining the results generated by these parsers into a single value with a function of the correct arity produced by the first parser. This is a clean way of putting together multiple parsers and getting a meaningful result out.
Attributes
- Since
-
4.0.0
- Example
-
scala> import parsley.character.char scala> import parsley.ap.{ap2, ap3} scala> case class Add(x: Int, y: Int) scala> val p = ap2(pure(Add), char('a').as(4), char('b').as(5)) scala> p.parse("ab") val res0 = Success(Add(4, 5)) scala> val q = ap3(pure((x: Int, y: Int, z: Int) => x * y + z), char('a').as(3), char('b').as(2), char('c').as(5)) scala> q.parse("abc") val res1 = Success(11) scala> q.parse("ab") val res2 = Failure(..)
- Source
- ap.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
ap.type
Members list
Value members
Inherited methods
This combinator allows the function that results from one parser to be applied to the result of another parser.
This combinator allows the function that results from one parser to be applied to the result of another parser.
Effectively alias for <*>
, to be consistent with the other ap
variants.
Value parameters
- pf
-
the parser whose result is a function to map across the result of
p1
. - px
-
the second parser to perform.
Attributes
- Returns
-
a parser that applies the function
f
resulting frompf
to the resultx
of the parserp1
. - Inherited from:
- ap (hidden)
- Source
- ap.scala
$bodyAp
$bodyAp
Value parameters
- pf
-
$paramAp ten.
Attributes
- Returns
-
$returnAp
- Inherited from:
- ap (hidden)
- Source
- ap.scala
$bodyAp
$bodyAp
Value parameters
- pf
-
$paramAp eleven.
Attributes
- Returns
-
$returnAp
- Inherited from:
- ap (hidden)
- Source
- ap.scala
$bodyAp
$bodyAp
Value parameters
- pf
-
$paramAp twelve.
Attributes
- Returns
-
$returnAp
- Inherited from:
- ap (hidden)
- Source
- ap.scala
$bodyAp
$bodyAp
Value parameters
- pf
-
$paramAp thirteen.
Attributes
- Returns
-
$returnAp
- Inherited from:
- ap (hidden)
- Source
- ap.scala
$bodyAp
$bodyAp
Value parameters
- pf
-
$paramAp fourteen.
Attributes
- Returns
-
$returnAp
- Inherited from:
- ap (hidden)
- Source
- ap.scala
$bodyAp
$bodyAp
Value parameters
- pf
-
$paramAp fifteen.
Attributes
- Returns
-
$returnAp
- Inherited from:
- ap (hidden)
- Source
- ap.scala
$bodyAp
$bodyAp
Value parameters
- pf
-
$paramAp sixteen.
Attributes
- Returns
-
$returnAp
- Inherited from:
- ap (hidden)
- Source
- ap.scala
$bodyAp
$bodyAp
Value parameters
- pf
-
$paramAp seventeen.
Attributes
- Returns
-
$returnAp
- Inherited from:
- ap (hidden)
- Source
- ap.scala
$bodyAp
$bodyAp
Value parameters
- pf
-
$paramAp eighteen.
Attributes
- Returns
-
$returnAp
- Inherited from:
- ap (hidden)
- Source
- ap.scala
$bodyAp
$bodyAp
Value parameters
- pf
-
$paramAp nineteen.
Attributes
- Returns
-
$returnAp
- Inherited from:
- ap (hidden)
- Source
- ap.scala
$bodyAp
$bodyAp
Value parameters
- pf
-
$paramAp two.
Attributes
- Returns
-
$returnAp
- Inherited from:
- ap (hidden)
- Source
- ap.scala
$bodyAp
$bodyAp
Value parameters
- pf
-
$paramAp twenty.
Attributes
- Returns
-
$returnAp
- Inherited from:
- ap (hidden)
- Source
- ap.scala
$bodyAp
$bodyAp
Value parameters
- pf
-
$paramAp twenty-one.
Attributes
- Returns
-
$returnAp
- Inherited from:
- ap (hidden)
- Source
- ap.scala
$bodyAp
$bodyAp
Value parameters
- pf
-
$paramAp twenty-two.
Attributes
- Returns
-
$returnAp
- Inherited from:
- ap (hidden)
- Source
- ap.scala
$bodyAp
$bodyAp
Value parameters
- pf
-
$paramAp three.
Attributes
- Returns
-
$returnAp
- Inherited from:
- ap (hidden)
- Source
- ap.scala
$bodyAp
$bodyAp
Value parameters
- pf
-
$paramAp four.
Attributes
- Returns
-
$returnAp
- Inherited from:
- ap (hidden)
- Source
- ap.scala
$bodyAp
$bodyAp
Value parameters
- pf
-
$paramAp five.
Attributes
- Returns
-
$returnAp
- Inherited from:
- ap (hidden)
- Source
- ap.scala
$bodyAp
$bodyAp
Value parameters
- pf
-
$paramAp six.
Attributes
- Returns
-
$returnAp
- Inherited from:
- ap (hidden)
- Source
- ap.scala
$bodyAp
$bodyAp
Value parameters
- pf
-
$paramAp seven.
Attributes
- Returns
-
$returnAp
- Inherited from:
- ap (hidden)
- Source
- ap.scala
$bodyAp
$bodyAp
Value parameters
- pf
-
$paramAp eight.
Attributes
- Returns
-
$returnAp
- Inherited from:
- ap (hidden)
- Source
- ap.scala
$bodyAp
$bodyAp
Value parameters
- pf
-
$paramAp nine.
Attributes
- Returns
-
$returnAp
- Inherited from:
- ap (hidden)
- Source
- ap.scala