flatMap<B> method

Parser<E, B> flatMap<B>(
  1. Parser<E, B> f(
    1. A
    )
)

Chain with a parser-producing function.

When called on a Mapped node, fuses the map into the bind to eliminate an intermediate interpreter step.

Implementation

Parser<E, B> flatMap<B>(Parser<E, B> Function(A) f) {
  if (this case final Mapped<E, dynamic, A> m) {
    return FlatMap(m.source, (Object? v) => f(m.applyF(v)));
  }
  return FlatMap<E, A, B>(this, f);
}