Wiring Diagrams as Operads: Wiring diagrams (WDs) are a formal graphical syntax for connecting components, capturing how outputs of some components feed into inputs of others. Spivak showed that WDs can be rigorously treated as the morphisms of an operad (denoted
Categorical Structure and Modularity: Treating WDs as an operad provides a powerful algebraic framework for composition, modularity, and abstraction in computation. Just as a category encapsulates compositionality of single-input/single-output processes, an operad encapsulates multi-input compositional patterns (think of combining several components into one) (Cospans, Wiring Diagrams, and the Behavioral Approach | Azimuth). Each WD encodes a pattern of interconnection – which wires (data flows) link which subcomponents – abstracting away the specific behavior of the components. This enforces modularity: one can replace a sub-diagram (component) with another of the same interface without changing the overall wiring structure. The operad axioms (associativity of composition and identity wiring diagrams) ensure that complex compositions can be built in a well-defined, hierarchical manner (Cospans, Wiring Diagrams, and the Behavioral Approach | Azimuth). In essence, operads are the “rules of modularity” – if you can specify the interfaces of components, how they can be arranged and nested, you likely have an operad governing the system’s composition () ().
Syntax vs. Semantics – Functorial Interpretation: A wiring diagram itself is a syntactic object – a combinatorial description of how parts are connected. To give it meaning (semantics), one provides an operad algebra or model for the WD operad (). Concretely, an algebra of the operad is a functor
Self-Similarity and Hierarchical Semantics: Because wiring diagrams can be nested inside each other, they exhibit self-similarity: a whole diagram can play the role of a component in a larger diagram ([1305.0297] The operad of wiring diagrams: formalizing a graphical language for databases, recursion, and plug-and-play circuits). The operad formalism captures this by allowing an output interface of one diagram to match the input interface of another, so that diagrams compose. Identities in the operad are trivial wiring diagrams (wires that directly connect inputs to outputs one-to-one), and the operad’s laws ensure that plugging diagrams together is associative. This rigorous foundation means we can reason algebraically about complex networks of computation. The precise semantics of a WD is thus given in two steps: first, the operad describes the abstract syntax of interconnection; second, an algebra (interpretation) provides the semantics by mapping that syntax to an actual composed process (). For instance, Spivak defines an algebra
Example – Function Composition: As a simple example, imagine two components (boxes) representing functions, g(f(x)) or via some temporary variable). Thus, WDs can serve as a normal form for compositions – in fact, it has been shown that wiring diagrams can be used as normal forms for computations in symmetric monoidal categories, providing a unique, diagrammatic representation of composed morphisms () (). Unlike traditional string diagrams which are depicted geometrically, wiring diagrams are purely combinatorial data (like a graph or syntax tree), which makes them more amenable to manipulation by computer algorithms () ().
Abstraction of Duplication and Deletion: One notable aspect of Spivak’s wiring diagram operad is how it handles duplication or discarding of wires (data). In many computational settings, a single output may need to feed into two inputs (fan-out) or an input may be unused in a particular composition. The operad of WDs explicitly includes generators for duplicating a signal and for deleting (discarding) a signal (Cospans, Wiring Diagrams, and the Behavioral Approach | Azimuth). This means the operad’s morphisms distinguish between ordinary transformations and the special “structural” operations of copying or discarding data. Other formalisms, like monoidal categories, typically treat these via properties of the category (e.g. a Cartesian category has diagonals and projections to copy or delete). Spivak’s operad instead builds those primitives into the wiring syntax itself (Cospans, Wiring Diagrams, and the Behavioral Approach | Azimuth). This explicitness can be useful when reasoning about systems where not all inputs are used or where one input feeds multiple destinations. It also aligns with logical aspects: for instance, duplication corresponds to a logical conjunction (using the same value in two places), and deletion corresponds to existential projection (ignoring a value). By making these operations first-class elements of the operad, the wiring diagram framework can uniformly capture the flow of information including branching and merging of data streams. This careful treatment of wiring semantics ensures the operad can model a wide range of computational structures, including those that require fan-out or are not purely linear flows (Cospans, Wiring Diagrams, and the Behavioral Approach | Azimuth).
In summary, the formal foundation of WDs is an operadic syntax for compositional systems. It provides a categorical algebra of wiring diagrams where composition = connecting outputs to inputs, and an interpretation (via operad algebras) gives semantics to those diagrams in any domain of interest. This framework guarantees that notions of composition, modular design, and abstraction can be treated with mathematical rigor, which is essential for reasoning about complex programs and systems in a principled way.
David I. Spivak has been a leading figure in developing the theory of wiring diagrams and exploring their applications in computer science. His key contribution is the identification and formalization of the operad of wiring diagrams as a unifying language for diverse compositional systems. In his 2013 paper “The operad of wiring diagrams: formalizing a graphical language for databases, recursion, and plug-and-play circuits”, Spivak introduced the operad
Building on the base operad, Spivak (often with collaborators) extended the idea to more specialized operads and algebras. For example, with Dylan Rupel he developed the operad of temporal wiring diagrams ([1307.6894] The operad of temporal wiring diagrams: formalizing a graphical language for discrete-time processes). This variant, introduced in Rupel & Spivak 2013, incorporates a notion of time or sequencing in the wires. In the temporal wiring diagrams operad (often denoted
In addition to these foundational papers, Spivak has delivered talks and written expository work situating operads of WDs in broader applied category theory. He emphasized that operads are a general tool for modular design — the “mathematics of modular systems” — and wiring diagrams are a prime example of how to formalize modularity () (). His presentations (e.g. “Operads for Modular Design” (2015) and “A Mathematical Language for Modular Systems” (2015)) illustrated WDs with numerous examples: from simple circuits to more abstract “circuits” of database tables or mathematical formulas (A mathematical language for modular systems David I. Spivak Presented on 2015/01/29) (A mathematical language for modular systems David I. Spivak Presented on 2015/01/29). In the database example, each box is a database table (with input/output ports representing foreign key links), and a wiring diagram specifying how tables join corresponds to a structured query (A mathematical language for modular systems David I. Spivak Presented on 2015/01/29) (A mathematical language for modular systems David I. Spivak Presented on 2015/01/29). By developing the operad-algebra approach in this way, Spivak extended traditional categorical structures (like monoidal categories used for string diagrams) to a more flexible, multi-typed, and hierarchical setting. Traditional string diagram formalisms assume one fixed monoidal category (one type of wire) and planar compositions; Spivak’s operads handle typed wires (each port can have a label or type), multiple nested levels, and explicit handling of duplication/deletion as noted earlier. This can be seen as an extension of category theory’s descriptive power for computation: rather than just saying “morphisms compose”, operads can say “complex networks of morphisms compose according to these patterns.” It bridges the gap between theory and engineering: the operad of WDs acts as a theoretical backbone that can describe plug-and-play hardware components, software modules, or data pipelines all within the same algebraic framework ([1305.0297] The operad of wiring diagrams: formalizing a graphical language for databases, recursion, and plug-and-play circuits).
Spivak’s work also connects to many themes in applied category theory (ACT). For instance, the operad of WDs has been related to decorated cospan categories (another formalism for composing open systems). Baez and Fong (2015) discuss how Spivak’s operad approach and the cospan approach are essentially equivalent ways of capturing networks and interconnections (Cospans, Wiring Diagrams, and the Behavioral Approach | Azimuth). Both frameworks enforce the idea of “compositionality” for complex systems, though Spivak’s operad formalism highlights the role of copying and deleting inputs explicitly (Cospans, Wiring Diagrams, and the Behavioral Approach | Azimuth). This connection is important in ACT because it means results and intuitions from one framework (say, network compositionality via cospans) can inform the other (operads of WDs) and vice versa. Moreover, Spivak and collaborators applied wiring diagram operads to dynamical systems and control theory. In a 2016 paper by Schultz, Spivak, and Vasilakopoulou, they provided a framework for composing Moore machines (a type of state machine) using directed wiring diagrams (Wiring diagrams for Mealy machines – Topos Institute). By treating state machines as boxes with stateful behavior, and wiring them, they could model complex automata compositionally. This line of work indicates how WDs serve as a meeting point for computer science (automata, circuits, programs) and other fields like biology or engineering (where dynamical system models are common). Indeed, in 2018–2020, Spivak joined the Topos Institute and continued exploring applications of wiring diagrams to areas such as neural networks and knowledge representation (for example, using “neural wiring diagrams” to describe message-passing in multi-scale systems (Neural wiring diagrams for message passing in multiscale ...)).
Another significant contribution is the influence Spivak’s work had on others, leading to a rich literature on WDs. Donald Yau’s “Operads of Wiring Diagrams” monograph (2018) builds on Spivak’s foundation and provides a comprehensive study of the combinatorial structure of various wiring diagram operads ([1512.01602] Operads of Wiring Diagrams). Yau gives finite presentations (generators and relations) for the operad of directed WDs (eight generators and 28 relations are needed, reflecting things like merging wires, splitting, etc.) ([1512.01602] Operads of Wiring Diagrams). He also studies algebras for these operads, including the propagator algebra, the algebra of discrete dynamical systems, the algebra of open dynamical systems, and the typed relational algebra, providing finite presentations for each ([1512.01602] Operads of Wiring Diagrams). These correspond exactly to the kinds of applications Spivak envisioned: propagators (in AI and programming languages), discrete-time systems, open continuous systems, and database relations. Furthermore, Spivak’s conjectures (such as one about the “quotient-freeness” property of the relational algebra on WDs) have been examined and partially verified in Yau’s work ([1512.01602] Operads of Wiring Diagrams). This signifies that Spivak’s initial ideas opened up a new research direction in category theory and theoretical computer science, inspiring others to deepen the theoretical understanding and expand the range of operadic models.
In summary, David Spivak’s contributions established wiring diagrams as a versatile, formal language for composition and provided concrete examples in computing (databases, circuits, etc.) to demonstrate their utility. He extended classical categorical approaches by using operads to handle multi-component composition with explicit wiring. His research and collaborations showed that the operad of WDs is not just a theoretical curiosity, but a practical tool for applied category theory, enabling cross-disciplinary modeling of complex, modular systems. Spivak’s work paved the way for using category theory in computation in a more structured way, influencing everything from how we might design query languages to how we might build modular software or reason about stateful systems.
One of the notable alignments of wiring diagram methodology is with declarative programming paradigms. Declarative programming (such as functional or logic programming) is characterized by describing what the program should accomplish – relationships between inputs and outputs or logical conditions – rather than explicitly detailing how to execute step by step (as in imperative programming). Wiring diagrams naturally emphasize the structure of connections and the relationships between components, which is very much a “what, not how” description. A WD specifies that “the output of component A is connected to the input of component B” and so on, essentially describing a dataflow or dependency graph. It does not inherently specify the order of execution or the mechanism by which data moves – those are either determined by the semantics (for example, data flows when available, or all functions compute simultaneously in a combinatorial circuit) or left abstract. This makes WDs a good fit for representing programs in a declarative, dataflow style.
Functional Programming: In a pure functional paradigm, programs are built by composing functions, often without side effects. This composition is naturally visualized as a directed acyclic graph of data flowing from one function to the next. Wiring diagrams can directly capture this: each function is a box, and if the output of
Logic and Constraint Programming: Wiring diagrams can also represent relations rather than functions, which connects to logic programming (where programs are sets of logical relations or constraints). In a logic program, one might have predicates
Non-Imperative Models and Abstraction: Because WDs focus on high-level connectivity, they can encapsulate paradigms like dataflow programming, functional reactive programming, and model-based design, all of which are more declarative than writing imperative code. A dataflow graph (like in streaming data processing frameworks) is essentially a wiring diagram of transformations and merges; one declares the graph, and the runtime handles data propagation. Wiring diagrams could formally represent such graphs. In functional reactive programming (FRP), one describes how outputs react to inputs over time in a declarative manner (“connect this signal to that, apply this function”), which again is naturally a wiring diagram of signal processors. The temporal operad
In all these cases, wiring diagrams provide a visual, declarative specification of a computation. The programmer or modeler specifies the what (which components are connected, hence which functional or logical relationships exist) and not the low-level how. Even complex control structures can be represented: e.g., a conditional can be seen as a wiring diagram that uses a boolean input to select between two sub-computations (a multiplexer), which is again a structural description. Iteration or recursion can be represented by feedback loops in the diagram (though, as noted, executing such loops may require a semantics with state or fixed-point solutions). The advantage of WDs in declarative terms is that they encourage thinking in terms of compositional components and their relationships, mirroring the way one might reason about a problem logically or functionally.
Another perspective is that WDs are akin to writing equations in a point-free style (as in some functional programming), where one connects operations without naming intermediate variables. The wires are the intermediate variables implicitly. This point-free, relational style is common in declarative specifications (for instance, in SQL or in functional combinator libraries) and WDs make it concrete and visual.
In conclusion, wiring diagrams align closely with declarative paradigms by capturing program structure without fixing an execution order or algorithm. Whether representing pure functions, logical constraints, or stream processors, a WD declares a network of relationships. The actual computation (evaluation, solving, data propagation) is something that happens when an interpretation is applied. This separation of concerns (specification vs execution) is a core idea in declarative programming. Spivak’s operad-of-WD approach thus provides a formal bridge between category theory and declarative programming models: it gives a precise language to talk about how pieces of a program are connected, which is exactly the level of abstraction at which declarative programmers prefer to work.
Since Spivak’s introduction of wiring diagrams as an operadic framework, there has been a growing body of research exploring how WDs can encode computational constructs and how they compare or integrate with other models of computation. Here we survey some key developments and applications:
-
Visual and Dataflow Programming: The idea of representing programs as node-and-wire diagrams is not new in practice – tools like LabVIEW, Simulink, Scratch, and various dataflow languages have been popular for years. What Spivak’s work contributes is a rigorous semantics and algebraic framework for such diagrams. Researchers have begun leveraging WDs to formally reason about and implement visual programming models. For instance, wiring diagrams can serve as the backbone of visual dataflow frameworks by providing a clear compositional semantics: each node (box) is an operation and each wire is a data channel. Unlike ad-hoc visual languages, using WDs ensures that the composition of components is associative, has identity elements, and can be manipulated algebraically. There are now software libraries (in the spirit of Spivak’s approach) for constructing and executing wiring-diagram-based programs. One example is the AlgebraicJulia ecosystem (developed by Evan Patterson, James Fairbanks, and others), which includes Catlab.jl – a library for applied category theory that implements operads and wiring diagram structures. With such tools, one can encode a flowchart or dataflow diagram as a formal operad morphism and then execute or analyze it within Julia. This kind of research sits at the intersection of programming languages and category theory, and it holds promise for making correct-by-construction visual programming environments. The literature in this area often overlaps with applied category theory conferences (e.g., the Applied Category Theory proceedings) where papers demonstrate case studies like wiring-diagram representations of computational workflows, and how they can be transformed or optimized using algebraic laws.
-
Dynamical Systems and State Machines: A significant application of WDs has been in modeling stateful systems such as automata or dynamical systems. We already mentioned that Schultz, Spivak, and Vasilakopoulou (2016) used directed wiring diagrams to compose Moore machines (finite state machines where output depends only on state) (Wiring diagrams for Mealy machines – Topos Institute). In their framework, each Moore machine is a box with a given state space and input/output types, and a wiring diagram composes these machines by connecting outputs to inputs (and implicitly, wiring the state transitions in a consistent way). This allows complex state machines to be built from simpler ones modularly. More recently, D’Angelo (2024) and others at Topos Institute have worked on dependent directed wiring diagrams to handle Mealy machines (where output can depend on both state and input) (Wiring diagrams for Mealy machines – Topos Institute) (Wiring diagrams for Mealy machines – Topos Institute). By enriching the wiring diagram operad to pass along global context (like a current state) to components, they can capture systems where the interconnection involves shared state. This line of research shows that WDs can express control flow and state sharing in programs: for example, an elevator controller was modeled as a Mealy machine via dependent wiring diagrams, illustrating how instantaneous input signals can affect outputs (Wiring diagrams for Mealy machines – Topos Institute) (Wiring diagrams for Mealy machines – Topos Institute). These works contribute to program representation by demonstrating that constructs like finite state machines, which are fundamental in programming (think of automata-based implementations, stateful loops, event-driven systems), can be composed and visualized with wiring diagrams. The advantage of using WDs here is that one can ensure consistency (no mismatched interfaces) and exploit algebraic properties (e.g., state composition might form a monoidal product) to simplify or analyze the composed system.
-
Symmetric Monoidal Categories and String Diagrams: As mentioned earlier, symmetric monoidal categories (SMCs) underlie the string diagram formalism often used to reason about programs (particularly in quantum computing, concurrency, and circuit theory). Patterson, Spivak, and Vagner (2021) made the relationship explicit: they showed that wiring diagrams can serve as normal forms for computations in SMCs, meaning that any algebraic composition in a SMC has a unique representation as a WD () (). Their work bridges the gap between low-level algebraic expressions and high-level diagrams. One outcome of their research is that one can use WDs to compute with morphisms in a category – by manipulating diagrams instead of algebraic formulas. This has been applied to improve automated reasoning in proof assistants or computational category theory libraries, where representing a morphism as a wiring diagram (a certain data structure) can make checking equality or composing morphisms more efficient. The broader literature on this topic also compares WDs to other graphical calculi: for instance, hypergraph categories are another formalism where morphisms have multiple inputs/outputs and are depicted as diagrams (generalizing SMCs). It turns out that the operad of wiring diagrams for SMCs essentially captures the same information as hypergraph categories (). Thus, WDs provide a unifying framework that can embed Petri nets, circuits, and other graphical models known in computer science. Petri nets, for example, can be seen as a type of hypergraph where places and transitions form a bipartite graph; wiring diagrams could model a similar structure if we treat markings as tokens flowing along wires. Although Petri nets traditionally have their own theory (with tokens, firing rules, etc.), category theorists have shown they can be treated compositionally via operads or cospans. Spivak’s operad approach influenced some of these developments by offering an operadic viewpoint: e.g., there are operads whose algebras are Petri nets with certain interfaces (sometimes called “open Petri nets”). While a direct citation might be beyond scope, it’s worth noting that researchers like Baez, Courser, and Patterson have drawn parallels between wiring diagrams and Petri net formalisms in terms of compositional structure.
-
Tensor Networks and Graphical Calculi: Another domain of interest is tensor networks – diagrams used in quantum computing and numerical linear algebra to represent compositions of multilinear maps (tensors). A tensor network is essentially a graph where nodes are tensors and edges indicate index contractions between tensors. This is strikingly similar to a wiring diagram: each tensor can be seen as a box with multiple “ports” (indices), and connecting an output of one tensor to an input of another means setting those indices equal and summing over them (contraction). Wiring diagrams, especially undirected ones, can capture the abstract structure of a tensor network (ignoring the numeric values). In fact, a symmetric monoidal category of finite-dimensional vector spaces has string diagrams that correspond to exactly such networks. Using wiring diagrams as a formal syntax could, in principle, allow one to reason about tensor networks compositionally or even manipulate them with software. Some literature in applied category theory touches on this (e.g., using hypergraph categories to represent signal-flow graphs, which are mathematically analogous to certain tensor networks). While Spivak’s own work did not explicitly address tensor calculus, the operadic framework is general enough that it could encode these when the algebra
$H: \mathcal{W}\to \mathbf{Set}$ assigns to each interface a space of tensors of the appropriate shape, and to each wiring diagram the operation of contracting those tensors accordingly. -
Comparison to Other Formal Models: Wiring diagrams join a rich ecosystem of formal models for programs. Monoidal categories (and their string diagrams) we have discussed – they focus on compositions and tensor products, often assuming a fixed notion of sequential vs parallel composition. WDs generalize these by allowing typed connections and hierarchical nesting (operads allow an operation to contain sub-operations). Petri nets focus on concurrency and resource usage, providing a token semantics which WDs do not inherently have (WDs are more like the “skeleton” of connectivity, whereas Petri nets add a layer of token dynamics). However, frameworks exist to recast Petri nets as wiring-diagram-like structures: for example, by treating a Petri net transition as a box whose “wires” are the places (with multiple wires possibly meaning multiple tokens) – though one must incorporate an effect for token consumption/production. Cospan categories and graph rewriting approaches model open networks by gluing interfaces; they have been shown to be equivalent in power to the operad approach (Cospans, Wiring Diagrams, and the Behavioral Approach | Azimuth). The difference is mostly in presentation: cospans focus on connecting via pushouts in category theory, while operads like WDs focus on a term-like composition (substitution into placeholders). Researchers have established formal relationships proving these approaches coincide under certain conditions, meaning one can choose the framework that is more convenient. The wiring diagram operad tends to make duplication and deletion explicit, whereas cospans implicitly allow merging or forgetting connections (Cospans, Wiring Diagrams, and the Behavioral Approach | Azimuth). This distinction can matter in programming language semantics: for instance, in a linear logic or resource-sensitive setting, you might restrict those structural operations – something easily stated in operad terms by removing those generators.
-
Applied Case Studies: Beyond theoretical comparisons, various case studies have demonstrated the use of WDs in specific computational contexts. For example, Spivak and others applied wiring diagrams to robotics and planning by representing knowledge-based plans as operadic diagrams (one of the AlgebraicJulia publications deals with a “categorical representation language for planning” which is essentially a wiring-diagram style model). In biological computation and chemical reaction networks, wiring diagrams have been used to represent interactions and then apply compositional analysis (Baez et al. 2022 used stock-and-flow diagrams, a kind of wiring diagram, to model epidemiological processes (AlgebraicJulia)). In distributed systems and protocols, a wiring diagram can depict how different agents’ processes connect, and operad algebras can enforce communication semantics. The literature is expanding as the operad of WDs is a convenient lingua franca for many network-like systems. Each of these applications treats WDs as a way to encode a system’s structure (like a program or process graph), sometimes converting it into executable code or into mathematical analysis. For instance, a visual programming interface could let a user draw a wiring diagram, and behind the scenes, this is compiled (via a chosen operad algebra) into executable code (SQL queries, or a circuit netlist, or actual machine instructions calling functions in order).
In summary, existing research on WDs for program representation spans from highly theoretical work (showing WDs are normal forms in monoidal categories () ()) to very practical applications (using WDs to design and compose real systems like state machines (Wiring diagrams for Mealy machines – Topos Institute) or dataflow pipelines). WDs act as a unifying model that can capture aspects of other models (monoidal categories’ diagrams, Petri net structures, etc.), often providing a more flexible or algebraically convenient perspective. The consensus in recent literature is that wiring diagrams (and operads in general) are a powerful tool for structured, modular representation of programs and processes, especially when one wants to ensure compositionality and reuse. They bring the benefits of visual formalisms (intuitive and high-level) together with formal rigor (well-defined semantics and algebraic manipulations). As a result, we see WDs being employed in domains ranging from formal verification to domain-specific language design, essentially wherever one can identify a network of interacting parts that would benefit from a high-level schematic representation.
Given the solid theoretical foundation and growing body of research, one can envision developing a system (framework or language) for modeling actual programs using wiring diagrams. Such a system would allow programmers to design, analyze, and even execute programs in a wiring diagram form. To achieve this, several considerations and components come into play:
1. Theoretical Considerations: We must define how various programming constructs map into the wiring diagram paradigm. Simple function composition and dataflow is straightforward, but what about conditional branching, looping, or recursion? As discussed, WDs can represent conditionals by having a wiring structure that splits the flow (one input goes into two different computations and a selector chooses one output to pass on). Loops or recursive calls correspond to feedback wires. A modeling system would likely differentiate between acyclic diagrams (which correspond to straight-line, feed-forward computations) and diagrams with feedback (which correspond to loops or stateful behavior). This might mirror how programming languages handle recursion or loops via fixed-points or state. One theoretical approach is to use guarded or temporal operads: for example, a feedback loop in a flow of data might require a delay (as in a state update each time step). Indeed, Spivak’s temporal wiring diagrams include a notion of delay to handle feedback in a causal way ([1512.01602] Operads of Wiring Diagrams). A program modeling system might therefore incorporate a temporal or iterative extension to the basic WD operad to ensure well-defined semantics for loops (avoiding instantaneous self-dependency). Type systems are another consideration: WDs should have typed ports (e.g. an integer output can only connect to an integer input). The operad formalism already supports this by having many objects (each interface is essentially a type or tuple of types), so our system would need a clear type checking rule (which is inherent: a wire can only connect matching types). For more complex typing features (like polymorphism or higher-order wiring diagrams where a box could itself contain a subdiagram as data), richer categorical structures (operads enriched over type categories or higher operads) might be required, but those are active research areas.
2. Frameworks and Tools: On the practical side, implementing WDs for program modeling involves both a frontend (perhaps a visual or textual language to specify wiring diagrams) and a backend (an interpreter or compiler that maps the WD into executable semantics). There are already some tools from the ACT community. For example, Catlab.jl (a Julia library) provides a way to construct operads and their algebras programmatically; it has been used to define wiring diagram operads and instantiate them with specific algebras (like circuits or relations). A domain-specific language or GUI on top of such a library could let programmers draw diagrams and then simulate or execute them. Another example is the Topos Institute’s software, where researchers are building interactive diagram editors that ensure the drawn diagram is formally a morphism in an operad or category. One could also integrate WD modeling into existing languages: for instance, a Haskell or Python library that allows constructing a wiring diagram via code and then “running” it by providing an interpretation. Some early prototypes treat wiring diagrams akin to electronic circuits, where you can compile them into a lower-level language (like how hardware description languages compile block diagrams to logic gates). As a concrete illustration, one might create a visual programming environment where the user drags and drops blocks (functions, conditionals, etc.) and wires them. Under the hood, each block is an element of some operad algebra (maybe a snippet of code or a function object), and the wiring diagram is automatically translated to a composition of those blocks. The system could then either generate actual source code (e.g., generate a Python function that corresponds to the drawn diagram) or directly execute the diagram by following the operad algebra’s composition (essentially acting as an interpreter).
3. Challenges: Developing such a system is not without challenges. One fundamental challenge is handling state and side effects. Pure wiring diagrams excel at describing static compositions, but real programs often have stateful interactions, side effects (I/O, mutation), and non-determinism. Modeling these in a wiring diagram requires careful design of the semantic algebra. For instance, to model mutable state, one might include explicit state-carrying wires or boxes that represent reading/writing to state. This starts to resemble the dataflow models used in languages like Lustre or LabVIEW for stateful systems, where there are feedback loops and special delay nodes. Ensuring that side effects happen in the right order might require encoding a notion of sequence or using a monadic style interpretation (for example, treat the entire program as a single state-transformer box that wires through an implicit “world state”). Another challenge is scalability and readability. While wiring diagrams are great for high-level views, large programs could become unwieldy if fully expanded into a single diagram. Hierarchical design (the ability to collapse sub-diagrams into abstract boxes) is crucial – operads support this by nature (a sub-diagram can be considered a single box via the operad’s composition), but tool support is needed to allow zooming in and out of detail. There’s also the question of human factors: programmers are used to textual code, and while visual languages have their appeal, they can also be slower for certain tasks. A compromise might be a hybrid approach where the program is written in a high-level declarative language that is isomorphic to a wiring diagram, and one can toggle between the textual and graphical view. Ensuring the synchronization of these views and efficient editing is a software engineering challenge.
From a research perspective, another challenge and opportunity is to leverage the algebraic laws of the operad to optimize or verify programs. If two wiring diagrams are algebraically equivalent (via the axioms of the operad and possibly additional equations if the algebra has some), the system could automatically simplify the diagram or recognize a refactoring. For example, a wire that splits into two and then those two wires feed into a merging operation that just recombines them could be simplified out. These kinds of rewrites relate to classical compiler optimizations but at a diagrammatic level. Researchers in computational category theory have explored using rewrite rules on wiring diagrams as a form of equational reasoning or program optimization. One could incorporate a rewriting engine that ensures the diagram remains in a simplified or canonical form, thereby helping with efficiency or clarity.
4. Future Directions: The future of using WDs for program representation likely involves integrating with modern programming language features and paradigms. One direction is to incorporate concurrency explicitly: since WDs already look like concurrent models (multiple components operating in parallel, communicating via wires), extending the framework to reason about concurrent execution, synchronization, or even probabilistic behavior could be fruitful. Another direction is linking WDs with software architecture: at a higher level, one could use wiring diagrams to model the interaction of microservices or modules in a large software system, treating each service as a box and communication channels as wires. This becomes a blueprint of the system architecture, on top of which one can map actual implementations. Because operads allow nested diagrams, this could naturally represent a hierarchy of system -> subsystems -> components.
On the theoretical side, ongoing research is looking at polynomial functors and polynomial monads as a foundation for wiring diagrams (Spivak and collaborators have related WDs to polynomial functors, which capture the idea of “a bunch of inputs produce an output” in a type-theoretic way (Neural wiring diagrams for message passing in multiscale ...)). This could eventually lead to new type-safe programming languages where a program is literally a polynomial morphism – essentially a wiring diagram with dependent types.
Another exciting prospect is combining wiring diagrams with machine learning or synthesis. For instance, given a specification (also possibly in WD form), can an algorithm synthesize a wiring diagram (i.e., compose library components to meet the spec)? The algebraic structure might make this more tractable by providing clear composition rules and a search space structured by the operad.
In conclusion, developing a full-fledged system for modeling programs with WDs will require both theoretical insights (to handle advanced language features declaratively in the operadic framework) and practical engineering (to build user-friendly tools and efficient execution engines). The research so far provides a strong proof-of-concept that many forms of computation can be captured by wiring diagrams – from pure functions to state machines and beyond. As the field progresses, we expect to see more programming environments influenced by Spivak’s operad of WDs, especially in areas where correctness, compositionality, and clarity of design are paramount. Such a system would enable programmers to think in terms of modular, interconnected parts, using a high-level visual language underpinned by rigorous semantics, ultimately improving our ability to build and reason about complex software and systems.
Sources:
-
Spivak, D.I. “The operad of wiring diagrams: formalizing a graphical language for databases, recursion, and plug-and-play circuits.” 2013. ([1305.0297] The operad of wiring diagrams: formalizing a graphical language for databases, recursion, and plug-and-play circuits) ([1305.0297] The operad of wiring diagrams: formalizing a graphical language for databases, recursion, and plug-and-play circuits)
-
Rupel, D., & Spivak, D.I. “The operad of temporal wiring diagrams: formalizing a graphical language for discrete-time processes.” 2013. ([1307.6894] The operad of temporal wiring diagrams: formalizing a graphical language for discrete-time processes) ([1307.6894] The operad of temporal wiring diagrams: formalizing a graphical language for discrete-time processes)
-
Patterson, E., Spivak, D.I., & Vagner, D. “Wiring diagrams as normal forms for computing in symmetric monoidal categories.” 2021 () ()
-
Baez, J., & Fong, B. “Cospans, Wiring Diagrams, and the Behavioral Approach.” Azimuth blog. 2015 (Cospans, Wiring Diagrams, and the Behavioral Approach | Azimuth) (Cospans, Wiring Diagrams, and the Behavioral Approach | Azimuth)
-
Yau, D. “Operads of Wiring Diagrams.” 2018 (Lecture Notes in Math. 2192) ([1512.01602] Operads of Wiring Diagrams)
-
D’Angelo, K. “Wiring diagrams for Mealy machines.” Topos Institute Blog, Aug 2024 (Wiring diagrams for Mealy machines – Topos Institute) (Wiring diagrams for Mealy machines – Topos Institute)
-
Spivak, D.I. Talk: “Operads for Modular Design” (slides, 2015) () (A mathematical language for modular systems David I. Spivak Presented on 2015/01/29)