Pipes — Mapanare

Compose agents into type-checked multi-stage pipelines.

Overview

Pipes compose multiple agents into named pipelines using the |> operator. The compiler verifies that the output type of each stage matches the input type of the next. Pipelines can be spawned and used like a single agent.

Defining a Pipe

agent Tokenizer {
    input text: String
    output tokens: List<String>
    fn handle(text: String) -> List<String> { return text.split(" ") }
}

agent Counter {
    input tokens: List<String>
    output count: Int
    fn handle(tokens: List<String>) -> Int { return tokens.len() }
}

pipe WordCount { Tokenizer |> Counter }

Using Pipes

fn main() {
    let wc = spawn WordCount()
    wc.text <- "hello world from mapanare"
    let result = sync wc.count
    print(result)  // 4
}

Multi-Stage Pipelines

pipe NLPPipeline { Tokenizer |> Normalizer |> Embedder |> Classifier }

Each stage runs concurrently. Pipes support pub for cross-module visibility.