The result of a parse--a Parser[A] returns a Result[A].
There are three cases:
Success(a,n): a is the value, n is # of consumed characters
Slice(n): a successful slice; n is the # of consumed characters
Failure(n,isCommitted): a failing parse
As usual, we define some helper functions on Result.
Defining functions on Result gives us better type
information--there are cases (see map and map2 below) where
Scala will not appropriately refine type information when
pattern matching on Result.
The result of a parse--a
Parser[A]
returns aResult[A]
.There are three cases:
As usual, we define some helper functions on
Result
. Defining functions onResult
gives us better type information--there are cases (seemap
andmap2
below) where Scala will not appropriately refine type information when pattern matching onResult
.