What are common stream pipeline errors in EK9?

← Streams and Pipelines · Ref: Q812

EK9 stream pipelines validate function signatures and types at compile time. Common errors involve head/tail/skip arguments, filter predicates, and type mismatches.

HEAD, TAIL, SKIP ARGUMENTS

These limiting operators accept:
- No argument (defaults to 1): cat items | head > result
- Integer literal (must be > 0): cat items | head 5 > result
- Integer variable: cat items | head with limit > result
- Supplier function (no params, returns Integer): cat items | head JustOne > result

Using zero, negative, non-integer, or functions with parameters triggers compile errors.

FILTER AND SPLIT

Filter requires a predicate (returns Boolean):

  cat items | filter by isPositive > result

The function must take one parameter matching the stream type and return Boolean.

CALL AND ASYNC

Stream call/async execute function delegates flowing through the pipeline:

  cat [getSteve, getLimb] | call > collector

Functions must be zero-argument suppliers returning a value. Non-function types, void functions, and functions requiring parameters are all compile errors.

See Q126 for complete stream reference. See Q204 for black-box tests.

Example

defines module qa.streams.pipeline.errors

  defines function

    JustOne()
      <- rtn <- 1

    JustDate()
      <- rtn <- 2024-10-01

    AcceptsArgument()
      -> arg0 as Integer
      <- rtn as Integer: arg0

    isShort() as pure
      -> item as String
      <- rtn as Boolean: item.length() < SHORT_THRESHOLD

  defines constant
    SHORT_THRESHOLD <- 5

  defines program

    StreamHeadDemo()
      stdout <- Stdout()

      // === head with no argument (defaults to 1) ===
      cat ["alpha", "beta", "gamma"]
        | head
        > stdout

      // === head with integer literal ===
      cat ["alpha", "beta", "gamma"]
        | head 2
        > stdout

      // === head with supplier function (reference) ===
      cat ["alpha", "beta", "gamma"]
        | head JustOne
        > stdout

      // === head with supplier function (call) ===
      cat ["alpha", "beta", "gamma"]
        | head JustOne()
        > stdout

      // === filter with predicate ===
      cat ["hi", "hello", "hey", "greetings"]
        | filter by isShort
        > stdout

Common mistakes

E07450 — Stream head/tail/skip supplier functions must take no parameters. AcceptsArgument requires an Integer argument so cannot be used as a count supplier. See ek9 -h E07450 for details.

Incorrect:

| head AcceptsArgument

Correct:

| head JustOne

E07870 — Stream head/tail/skip function call must return Integer. JustDate returns a Date which cannot provide a count. See ek9 -h E07870 for details.

Incorrect:

| head JustDate()

Correct:

| head JustOne()
Other ways to ask this
  • Why does my stream pipeline fail to compile in EK9?
  • How do I fix stream head/tail/skip errors in EK9?
  • What are the rules for stream limiting operators in EK9?

Coming from another language?

Java: Stream.limit(n) and skip(n) accept long — zero and negative accepted at compile time, fail at runtime. Python: itertools.islice accepts any integer silently. Rust: .take(n) and .skip(n) accept usize with no value validation. EK9: compile-time validation of positive integers, correct function signatures, and type compatibility throughout the pipeline.

Keywords: error, limit, call, filter, skip, tail, stream, pipeline, async, head