You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add pipeline operator |> for chaining data transformations, enabling clearer data flow without intermediate variables.
Problem
Current approach requires multiple statements with intermediate variables:
Extract the <raw-data> from the <request: body>.
Transform the <cleaned-data> from the <raw-data> with "trim".
Transform the <parsed-data> from the <cleaned-data> with "parse-json".
Validate the <valid-data> from the <parsed-data>.
Store the <valid-data> into the <repository>.
Solution
Add |> pipeline operator for left-to-right data flow:
Extract <data> from <request: body>
|> Transform with "trim"
|> Transform with "parse-json"
|> Validate
|> Store in <repository>.
(Process Request: API Handler) {
Extract <data> from <request: body>
|> Validate
|> Transform with "normalize"
|> Store in <repository>
|> Log to <audit-log>.
Return an <OK: status> with <data>.
}
Data Transformation Pipeline
(Clean User Data: Data Pipeline) {
Extract <users> from <raw-file>
|> Filter where status = "active"
|> Transform with "trim-whitespace"
|> Transform with "lowercase-email"
|> Sort by <created-date>
|> Store in <user-repository>.
Return an <OK: status>.
}
Object Implicit in Pipeline
Each stage receives the previous stage's result as implicit input:
(* Explicit *)
Extract the <data> from <source>.
Transform the <cleaned> from <data> with "trim".
Validate the <valid> from <cleaned>.
(* Pipeline - 'data' is implicit *)
Extract <data> from <source>
|> Transform with "trim" (* operates on <data> *)
|> Validate. (* operates on transformed result *)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
ARO-0067: Pipeline Operator
Abstract
Add pipeline operator
|>for chaining data transformations, enabling clearer data flow without intermediate variables.Problem
Current approach requires multiple statements with intermediate variables:
Solution
Add
|>pipeline operator for left-to-right data flow:Syntax
Lexer Token
Add
TokenKind.pipefor|>:Parser
Pipeline expression chains actions:
AST
Examples
API Request Processing
Data Transformation Pipeline
Object Implicit in Pipeline
Each stage receives the previous stage's result as implicit input:
Implementation
Lexer Change
Parser Change
Execution
Execute stages sequentially, passing result between stages:
Benefits
Compatibility
Fully backward compatible - existing code continues to work. Pipeline is opt-in syntax sugar.
Fixes GitLab #105
Canonical source:
Proposals/ARO-0067-pipeline-operator.mdonmain. Edits should be made there.All reactions