name.rayrobdod.stringContextParserCombinator.typeclass.Sequenced
See theSequenced companion object
@FunctionalInterface
Describes how to combine two adjacent values into one value
Below is example of defining and using a custom Sequenced:
import java.time._
import name.rayrobdod.stringContextParserCombinator.Interpolator.idInterpolators._
import name.rayrobdod.stringContextParserCombinator.typeclass.Sequenced
given Sequenced[LocalDate, LocalTime, LocalDateTime] with {
def aggregate(date:LocalDate, time:LocalTime):LocalDateTime = date.atTime(time)
}
val dateParser:Interpolator[LocalDate] = ofType[LocalDate]
val timeParser:Interpolator[LocalTime] = ofType[LocalTime]
val p: Interpolator[LocalDateTime] = dateParser andThen timeParser
p.interpolate(StringContext("", "", ""), LocalDate.of(2001, 02, 03) :: LocalTime.of(04, 05, 06) :: Nil) // `2001-02-03T04:05:06`: LocalDateTime
Type parameters
- A
-
the first input
- B
-
the second input
- Z
-
the result container
Attributes
- See also
- Companion
- object
- Source
- Sequenced.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
Members list
In this article