I have a fairly generic question. I am wondering, out of curiosity, whether one could model a graph like the following with types:
Basically every node should be an object mapping inputs to outputs but instead of just having a single input / output type it can have several ports on both ends. Composing these objects should work by connecting some ports to others as inputs. The new, composed object loses the connected ports and exposes the combined unconnected ones. I am interested in describing the full Graph on the type level so that it can be typechecked but also plotted.
I know that DAGs can be described with types via free Arrows but those would use nested, unnamed Tuples to describe the ports which really isn’t convenient at all and difficult to handle if the graph has lots of branches without Haskell’s proc notation. I wonder if Purescript’s extensible records (for product ports) and Variant types can’t be used to make this a lot more convenient. I also know that effect systems can be built on top of such DAGs (like kernmantle GitHub - tweag/kernmantle: Braiding extensible effects together in a pipeline/workflow of tasks) and that’s great but I don’t need this right now (although if you have an idea how to do this as well let me know).
Any ideas whether someone has done something similar or whether there is a principal problem with this?