Evaluating Linear Functions to Symmetric Monoidal Categories
Jean-Philippe Bernardy, Arnaud Spiwack

TL;DR
This paper introduces a Haskell library that uses linear typing to simplify programming with symmetric monoidal categories, enabling more natural embedding of diagram-based languages without metaprogramming.
Contribution
It presents a novel approach leveraging linear types in Haskell to directly program in SMCs, reducing syntactic overhead and avoiding metaprogramming.
Findings
Library enables embedding SMCs with linear functions
Reduces syntactic overhead to match monadic DSLs
Does not rely on metaprogramming techniques
Abstract
A number of domain specific languages, such as circuits or data-science workflows, are best expressed as diagrams of boxes connected by wires. Unfortunately, functional languages have traditionally been ill-equipped to embed this sort of languages. The Arrow abstraction is an approximation, but we argue that it does not capture the right properties. A faithful abstraction is Symmetric Monoidal Categories (SMCs), but,so far,it hasn't been convenient to use. We show how the advent of linear typing in Haskell lets us bridge this gap. We provide a library which lets us program in SMCs with linear functions instead of SMC combinators. This considerably lowers the syntactic overhead of the EDSL to be on par with that of monadic DSLs. A remarkable feature of our library is that, contrary to previously known methods for categories, it does not use any metaprogramming.
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
