jcberentsen/elm-wiring-diagrams/3.1.0

NOTE: the latest version is 5.4.7

WiringDiagram

Wiring diagrams

Inspiration

https://arxiv.org/pdf/2101.12046.pdf

Diagram type

type alias Diagram a =
Diagram a

Represent an abstract wire-diagram.

Think of boxes connected with ports, that can be inside other boxes (which connect outside) (TODO illustration)

init : Diagram a

Initialize an empty Diagram. The idea is a box with no label. The box is abstract and will be given geometry using the Layout module

Use modifiers like setInPorts to configure further

Custom use

initLabeled : Maybe a -> Diagram a

Initialize an empty Diagram with a label of a chosen type

All diagrams you intend to combine needs to have the same label type

diagram : { a | label : Maybe b, inner : List (Diagram b) } -> Diagram b

Wrap a diagram, exposing the free in and out ports

Diagram helpers

source : a -> Int -> Diagram a

Make a source with label a and a number of outPorts

sink : a -> Int -> Diagram a

Make a sink with label a and a number of inPorts

relation : a -> Int -> Int -> Diagram a

Make a relation with label a and a number of inPorts and outPorts

inSequence : List (Diagram a) -> Diagram a

Connect diagrams in a chain

inParallel : List (Diagram a) -> Diagram a

Put diagrams in parallel. No connections will be made. (We probably need to relabel ports here...)

setLabel : Maybe a -> Diagram a -> Diagram a

Assign a label to a Diagram

setLabel (Just "node") <| diagram --

Wrapping

Parts of a Diagram can be wrapped and given a label of its own (with setLabel)

initWrap : Diagram a -> Diagram a

Wrap a diagram, exposing the free in and out ports