Type-safe, Polyvariadic Event Correlation
Pith reviewed 2026-05-25 01:29 UTC · model grok-4.3
The pith
Event patterns with any number of variables can be embedded as a pure library using join notation while the host type system rejects all ill-typed cases.
A machine-rendered reading of the paper's core claim, the machinery that carries it, and where it could break.
Core claim
PolyJoin shows that a tagless final encoding with uncurried HOAS representation of event patterns with n variables, for arbitrary n, can be defined entirely inside the host language. The encoding exploits the host type system to model the pattern language, so that ill-typed patterns are impossible to write. The resulting library accepts the familiar join-query notation yet is not restricted to monadic semantics, and an implementation in multicore OCaml demonstrates that the embedding is practical, type-safe and extensible.
What carries the argument
tagless final encoding with uncurried higher-order abstract syntax (HOAS) for representing event patterns with n variables for arbitrary n
If this is right
- Event patterns become expressible in ordinary join notation inside a general-purpose language.
- No code generation is required to obtain the type safety guarantees.
- Correlation semantics can be polymorphic and are not forced into a monadic form.
- The same library mechanism can be extended with new correlation operators while preserving type safety.
- An implementation in multicore OCaml already demonstrates usability for realistic event workloads.
Where Pith is reading between the lines
- The same encoding technique might be applied to other polyvariadic query notations that currently rely on code generation.
- If the approach scales to larger n, it removes a practical barrier that has kept event correlation libraries from offering full static checking.
- Programmers could begin to treat complex event patterns as ordinary, type-checked library calls rather than as a separate language feature.
Load-bearing premise
A tagless final encoding with uncurried HOAS can represent and type-check fully polyvariadic patterns with polymorphic correlation semantics for arbitrary n while remaining a pure library without code generation.
What would settle it
A concrete implementation attempt in which a pattern containing a type mismatch between events and the correlation function still type-checks under the library would show the central claim is false.
Figures
read the original abstract
The pivotal role that event correlation technology plays in todays applications has lead to the emergence of different families of event correlation approaches with a multitude of specialized correlation semantics, including computation models that support the composition and extension of different semantics. However, type-safe embeddings of extensible and composable event patterns into statically-typed general-purpose programming languages have not been systematically explored so far. Event correlation technology has often adopted well-known and intuitive notations from database queries, for which approaches to type-safe embedding do exist. However, we argue in the paper that these approaches, which are essentially descendants of the work on monadic comprehensions, are not well-suited for event correlations and, thus, cannot without further ado be reused/re-purposed for embedding event patterns. To close this gap we propose PolyJoin, a novel approach to type-safe embedding for fully polyvariadic event patterns with polymorphic correlation semantics. Our approach is based on a tagless final encoding with uncurried higher-order abstract syntax (HOAS) representation of event patterns with n variables, for arbitrary $n \in \mathbb{N}$. Thus, our embedding is defined in terms of the host language without code generation and exploits the host language type system to model and type check the type system of the pattern language. Hence, by construction it impossible to define ill-typed patterns. We show that it is possible to have a purely library-level embedding of event patterns, in the familiar join query notation, which is not restricted to monads. PolyJoin is practical, type-safe and extensible. An implementation of it in pure multicore OCaml is readily usable.
Editorial analysis
A structured set of objections, weighed in public.
Referee Report
Summary. The paper claims that PolyJoin, a tagless-final encoding based on uncurried higher-order abstract syntax (HOAS), provides a purely library-level embedding of fully polyvariadic event patterns (arbitrary n) in familiar join-query notation inside a statically typed host language (OCaml). The encoding is said to enforce the pattern language's typing rules by construction, support polymorphic correlation semantics, remain free of monadic restrictions and code generation, and be practical and extensible.
Significance. If the central claim holds, the result would be significant: it supplies a non-monadic, library-only route to type-safe event correlation that directly exploits the host type system for safety and extensibility. The explicit availability of a pure multicore OCaml implementation is a concrete strength that supports reproducibility and usability claims.
major comments (1)
- [Abstract] Abstract (paragraph on PolyJoin approach): the claim that the uncurried-HOAS tagless-final encoding supports fully polyvariadic patterns 'for arbitrary n ∈ ℕ' and enforces type safety 'by construction' is load-bearing, yet the abstract supplies neither an inductive definition nor a proof sketch showing how the host-language types scale without bound or additional code generation; this gap prevents verification of the central type-safety guarantee.
minor comments (1)
- The abstract states that the approach is 'not restricted to monads' but does not contrast the encoding with monadic-comprehension descendants at the level of typing rules or example patterns; a short comparative table would clarify the claimed advantage.
Simulated Author's Rebuttal
We thank the referee for the detailed review and constructive feedback. We address the single major comment below, agreeing where the abstract is indeed concise and proposing a targeted revision.
read point-by-point responses
-
Referee: [Abstract] Abstract (paragraph on PolyJoin approach): the claim that the uncurried-HOAS tagless-final encoding supports fully polyvariadic patterns 'for arbitrary n ∈ ℕ' and enforces type safety 'by construction' is load-bearing, yet the abstract supplies neither an inductive definition nor a proof sketch showing how the host-language types scale without bound or additional code generation; this gap prevents verification of the central type-safety guarantee.
Authors: We acknowledge that the abstract, as a high-level summary, does not contain an inductive definition or proof sketch; these details appear in the body of the manuscript, where the tagless-final encoding is defined and the host-language type system is shown to enforce the pattern rules for any n. The uncurried HOAS representation is constructed so that the host type checker directly validates arity and typing without code generation or monadic wrappers. To make the central claim more self-contained in the abstract, we will add one sentence briefly indicating the scaling mechanism via the encoding. This revision addresses the concern without altering the manuscript's technical content. revision: yes
Circularity Check
No significant circularity
full rationale
The paper's central claim is a library-level tagless-final encoding with uncurried HOAS that embeds polyvariadic patterns and enforces their typing rules via the host language type system by construction. No load-bearing step reduces to a fitted parameter renamed as prediction, a self-citation chain, an ansatz smuggled via prior work, or a renaming of a known result. The derivation is self-contained: the type safety follows directly from the encoding's use of host-language types, with no equations or premises that equate to their own inputs.
Axiom & Free-Parameter Ledger
axioms (2)
- domain assumption The host language type system can model and enforce the type system of the event pattern language for arbitrary n
- domain assumption Uncurried HOAS with tagless final encoding suffices for polymorphic correlation semantics without code generation
invented entities (1)
-
PolyJoin encoding
no independent evidence
Reference graph
Works this paper leans on
-
[1]
The CQL continuous query language: Semantic foundations and query execution. The VLDB Journal (2006). 34 Bračevac, Salvaneschi, Erdweg, and Mezini Kenichi Asai
work page 2006
-
[2]
Higher-Order and Symbolic Computation 22, 3 (2009), 275–291
On typing delimited continuations: Three new solutions t o the printf problem. Higher-Order and Symbolic Computation 22, 3 (2009), 275–291. Engineer Bainomugisha, Andoni Lombide Carreton, Tom Van Cutsem, Stijn M ostinckx, and Wolfgang De Meuter
work page 2009
-
[3]
ACM Computing Surveys 45, 4 (2013)
A survey on reactive programming. ACM Computing Surveys 45, 4 (2013). Aggelos Biboudis, Nick Palladinos, George Fourtounis, and Yannis Sma ra gda kis
work page 2013
-
[4]
Versatile event correlation with algebraic effects. Proceedings of the ACM on Programming Languages (PACMPL) 2, International Conference on Functional Programming (ICFP) (9 2018). Paris Carbone, Asterios Katsifodimos, Stephan Ewen, Volker Markl, Seif Haridi, and Kostas Tzoumas
work page 2018
-
[5]
Apache flink ™ : Stream and batch processing in a single engine. IEEE Data Eng. Bull. 38, 4 (2015), 28–38. Jacques Carette, Oleg Kiselyov, and Chung-chieh Shan
work page 2015
-
[6]
Journal of Functional Programming 19, 5 (2009), 509–543
Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages. Journal of Functional Programming 19, 5 (2009), 509–543. Andrew Cave, Francisco Ferreira, Prakash Panangaden, and Brigitte Pient ka
work page 2009
-
[7]
Proceedings of the VLDB Endowment 8, 4 (2014), 401–412
Trill: A high-performance incremental query process or for diverse analytics. Proceedings of the VLDB Endowment 8, 4 (2014), 401–412. James Cheney and Ralf Hinze
work page 2014
-
[8]
ACM Computing Surveys 44, 3 (2012), 15:1–15:62
Processing flows of information: From data stream to complex event processing. ACM Computing Surveys 44, 3 (2012), 15:1–15:62. Olivier Danvy
work page 2012
-
[9]
Journal of Functional Programming 8, 6 (1998), 621–625
Functional unparsing. Journal of Functional Programming 8, 6 (1998), 621–625. Nicolaas Govert De Bruijn
work page 1998
-
[10]
Transactions on Programming Languages and Systems (TOPLAS) (2009)
Revisiting corou tines. Transactions on Programming Languages and Systems (TOPLAS) (2009). Stephen Dolan, Spiros Eliopoulos, Daniel Hillerström, Anil Madhava ped dy, KC Sivaramakrishnan, and Leo White
work page 2009
-
[11]
Scala Async. Retrieved June 11, 2018 from http://web.archive.org/web/20180611025539/https://github.com/scala/scala-async EsperTech Inc. 2006.Esper. Retrieved April 22, 2018 from https://web.archive.org/web/20180422212134/http://www.espertech.com/esper/ Patrick Eugster and K.R. Jayaram
-
[12]
Christian Hofer, Klaus Ostermann, Tillmann Rendel, and Adriaan Moors
Do we need dependent types? Journal of Functional Programming (2000). Christian Hofer, Klaus Ostermann, Tillmann Rendel, and Adriaan Moors
work page 2000
-
[13]
ACM Computing Surveys 28, 4es (1996),
Building domain-specific embedded languages. ACM Computing Surveys 28, 4es (1996),
work page 1996
-
[14]
Journal of Functional Programming (1997)
The zipper. Journal of Functional Programming (1997). Gérard Huet and Bernard Lang
work page 1997
-
[15]
Proving and applying program transformations expressed with second-order patterns. Acta Informatica (1978). John Hughes
work page 1978
-
[16]
Science of Computer Programming 37, 1-3 (2000)
Generalising monads to arrows. Science of Computer Programming 37, 1-3 (2000). Patricia Johann and Neil Ghani
work page 2000
-
[17]
Polyvariadic functions and keyword arguments: Pattern-ma tching on the type of the context . Retrieved October 10, 2018 from https://web.archive.org/web/20181013042601/http://okmij.org/ftp/Haskell/polyvariadic.html Oleg Kiselyov, Ralf Lämmel, and Keean Schupke
-
[18]
Journal of Functional Programming 12, 4&5 (2002), 375–392
Faking it: Simulating dependent types in haskell. Journal of Functional Programming 12, 4&5 (2002), 375–392. Conor McBride and Ross Paterson
work page 2002
-
[19]
Journal of Functional Programming (2008)
Applicative programming with effects. Journal of Functional Programming (2008). Erik Meijer, Brian Beckman, and Gavin Bierman
work page 2008
-
[20]
Information and computation 93, 1 (1991), 55–92
Notions of computation and monads. Information and computation 93, 1 (1991), 55–92. Luc Moreau
work page 1991
-
[21]
Higher-Order and Symbolic Computation 11, 3 (1998)
A syntactic theory of dynamic binding. Higher-Order and Symbolic Computation 11, 3 (1998). Alan Mycroft, Dominic A. Orchard, and Tomas Petricek
work page 1998
-
[22]
Simplicitly: Foundations and applications of implicit function types. Proceedings of the ACM on Programming Languages (PACMPL) 2, Symposium on Principles of Programming Languages (POPL) (2018). Bruno C.d.S. Oliveira and William R. Cook
work page 2018
-
[23]
In Proceedings of European Conference on Object-Oriented Pro gramming (ECOOP)
Feature-oriented programming with object algebras. In Proceedings of European Conference on Object-Oriented Pro gramming (ECOOP). Jennifer Paykin, Neelakantan R. Krishnaswami, and Steve Zdancewic. 2016 . The essence of event-driven programming. (2016). Unpublished Draft (https://web.archive.org/web/20161018163751/http://www.mpi-sws.org/~neelk/essence-of-e...
-
[24]
Applied Categorical Structures (2003)
Algebraic operations and ge neric effects. Applied Categorical Structures (2003). Gordon D. Plotkin and Matija Pretnar
work page 2003
-
[25]
Retrieved May 3, 2019 from https://web.archive.org/web/20190503085703/http://reactivex.io/ John C
Reactive Extensions. Retrieved May 3, 2019 from https://web.archive.org/web/20190503085703/http://reactivex.io/ John C. Reynolds
-
[26]
Programming Methodology: A Collection of Articles by Membe rs of IFIP WG2.3 (1978), 309–317
User-defined types and procedural data s tructures as complementary approaches to data abstrac- tion. Programming Methodology: A Collection of Articles by Membe rs of IFIP WG2.3 (1978), 309–317. Morten Rhiger
work page 1978
-
[27]
Journal of Functional Programming (2009)
Type-safe pattern combinators. Journal of Functional Programming (2009). Tiark Rompf and Martin Odersky
work page 2009
-
[28]
In Proceedings of Symposium on Principles of Programming Languages (POPL)
How to make ad-hoc polymo rphism less ad-hoc. In Proceedings of Symposium on Principles of Programming Languages (POPL) . Stephanie Weirich and Chris Casinghino. 2010a. Arity-generic datatype-g eneric programming. In Proceedings of the Work- shop on Programming Languages Meets Program Verification (P LPV). Stephanie Weirich and Chris Casinghino. 2010b. Gen...
work page 2010
-
[29]
Lisp and Symbolic Computation 8, 4 (1995)
Simple imperative polymorphism. Lisp and Symbolic Computation 8, 4 (1995). Jeremy Yallop and Leo White
work page 1995
discussion (0)
Sign in with ORCID, Apple, or X to comment. Anyone can read and Pith papers without signing in.