- The user creates a program by creating nodes and connecting them together, creating a directed graph.
- There are various types of node that each have their own behavior, and a set number of inputs, and outputs.
- Inputs and outputs are strongly typed; you can’t connect a
Stringoutput to an
Intinput for example.
- Any number of instances of a node can be created.
- The created graph must be acyclic; you might call it a Directed Acyclic Graph.
How would you model such an interface in Elm? I want to use the type system to create this as much as possible. Nodes, inputs, and outputs seem to lend themselves well to union types, but it’s unclear how I can model the state of each node in a way that makes it easy to query all of the nodes connected to it, without having double references where adjacent nodes have to “agree” that they are connected to each other.