An intermediate object with an apply
and flatMap
that both create a sequenced consumer
which combines this consumer with a function to create the next one.
An intermediate object with an apply
and flatMap
that both create a sequenced consumer
which combines this consumer with a function to create the next one.
Examples:
val c1: Consumer[In, A] = /* ... */ def getC2(c1Result: A): Consumer[In, B] = /* ... */ val combined: Consumer[In, B] = c1.followedBy(getC2) // alternative `flatMap` syntax val combined: Consumer[In, B] = for { c1Result <- c1.followedBy c2Result <- getC2(c1Result) } yield c2Result
An example of where this is useful is when a parser for XML element depends on values parsed from one of its previous siblings, but where you don't want to wait until the end of their parent element before they can be combined.
An intermediate object which has an apply
and flatMap
that can be used
to combine this Consumer and another in a sequence.
An intermediate object with an apply
and flatMap
that can be used to create a Transformer from result of this consumer.
An intermediate object with an apply
and flatMap
that can be used to create a Transformer from result of this consumer.
Examples:
val c1: Consumer[In, A] = /* ... */ def getStream(c1Result: A): Transformer[In, B] = /* ... */ val combined: Transformer[In, B] = c1.followedByStream(getStream) // alternative `flatMap` syntax val combined: Transformer[In, B] = for { c1Result <- c1.followedByStream c2Result <- getStream(c1Result) } yield c2Result
An example of where this is useful is when an XML element contains some "dictionary" object
at the beginning, followed by a sequence of "data" objects which reference the dictionary.
For large sequences, combining them to a List (to use with Parser's and
combiners) is undesireable;
we can use this approach to avoid doing so.
An intermediate object which has an apply
and flatMap
that can be used
to combine this consumer and a Transformer in a sequence.
Implicitly adds
followedBy
andfollowedByStream
to Consumers with Stackable input types. (Due to type variance conflicts between Consumer'sIn
type and Stackable's type, these methods can't be defined directly on Consumer.)The consumer's input type, which must be a member of the
Stackable
typeclassThe consumer's output type