jcberentsen / elm-wiring-diagrams / Cartesian.Examples

Example Cartesian diagrams with String labels

elm-wiring-diagrams

Usage

basicCell : Cartesian.C String

A basic cell with a label String of 'Cell'

a : Cartesian.C String

A cell with an 'a'

a =
    C.init "a"

b : Cartesian.C String

A cell with a 'b'

c : Cartesian.C String

A cell with a 'c'

d : Cartesian.C String

Wow a cell with a 'd'

abc : Cartesian.C String

We can compose a b and c in sequence Ah, now it is starting to make sense...

a |> C.before b |> C.before c

axb : Cartesian.C String

Compose a and b in parallel

a |> C.aside b

bxa : Cartesian.C String

Compose a and b in parallel but b first

axb_cxd : Cartesian.C String

Compose axb and cxd in sequence. We can expect a to connect with c and b to connect with d

let
    cxd =
        c
            |> C.aside d
in
axb |> C.before cxd

axb_cxd_e : Cartesian.C String

Compose axb and cxd in sequence before 'e' The 'e' node needs to be declared with 2 inputs so the outputs from both 'c' and 'd' will connect to it. Otherwise the 'd' output will be dangling (which is ok if something else will be connected later)

simpleBypass : Cartesian.C String

A simple bypass

let
    source =
        C.initWith 1 3 "src"

    sink =
        C.initWith 1 1 "sink"
in
source |> C.before (sink |> C.aside bxa)

bypass : Cartesian.C String

An example of how to make a bypass

let
    source3 =
        C.initWith 1 3 "src"

    sink2 =
        C.initWith 2 1 "sink"

    extraLane =
        C.init "bypass"

    conduce =
        axb_cxd_e |> C.aside extraLane
in
source3 |> C.before conduce |> C.before sink2

logo : Cartesian.C String

The diagram for the package logo

C.init "elm"
    |> C.before (C.init "wiring")
    |> C.before (C.init "diagrams")