Convert Neva programs to valid Mermaid diagrams
Use this skill to convert any Neva source code into a Mermaid flowchart.
Read the Neva code to be converted.
Generate a Mermaid flowchart TB diagram using the following rules:
Layout: Always include this header at the top:
---
config:
layout: elk
---
flowchart TB
Ports:
:in / :out:
([":data"]), ([":res"]), ([":err"]), etc.data, res, , , , etc).errsigcase[0]Components:
id["name: Type"].Component nodes (IMPORTANT):
Literals:
zero@{ label: "0", shape: rect }dot@{ label: "'.'", shape: rect }Connections:
-- <port> --> labels for the wire’s port name.a:out -> b:in, label the edge with the output port name (out), unless Neva explicitly uses the input port name in the wiring (e.g., b:sig).x:res -> y → label edge as resx -> y:sig → label edge as sigx:case[0] -> y → label edge as case[0]If a port name is omitted in Neva, do not infer or guess it. Render an unlabeled edge:
x -> y → x --> yFan-out / Fan-in (IMPORTANT):
jX(( )) where jX is a unique ID.Fan-out: src -> [a, b, :out]
jX(( )).src -- <port> --> jXjX --> a, jX --> b, jX --> out_portFan-in: [a, b] -> dst:port
jX(( )).a --> jX and b --> jXjX -- <port> --> dstGrouping (&):
& to reduce clutter only when it does not hide fan-in/fan-out topology.[...]), prefer junction nodes over &.Don't lookup otherfiles in repo and do not bother calling tools like websearch, this text describes absolutely everything you need.
Ensure the output is ready to be pasted into the Mermaid playground.
pub def Tap<T>(data T) (res T, err error) {
pass1 Pass<T>
pass2 Pass<T>
lock Lock<T>
handler ITapHandler<T>
---
:data -> [lock:data, handler]
handler:res -> pass1
handler:err -> [pass2, :err]
[pass1, pass2] -> lock:sig
lock -> :res
}