From 99b60bc9f128b8f89e3631c08699879995e637ae Mon Sep 17 00:00:00 2001 From: medusa Date: Wed, 6 Aug 2025 09:34:08 -0500 Subject: [PATCH] Update tech_docs/CUE_your_new_friend.md --- tech_docs/CUE_your_new_friend.md | 61 +++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/tech_docs/CUE_your_new_friend.md b/tech_docs/CUE_your_new_friend.md index a4c18c6..9d8bf3a 100644 --- a/tech_docs/CUE_your_new_friend.md +++ b/tech_docs/CUE_your_new_friend.md @@ -317,4 +317,63 @@ Type D = A | B - **Type C**: Since `int` and `string` are incompatible types, \(A \& B\) would result in the "Bottom" type (\(_|\_\)), indicating an error or conflict. - **Type D**: \(A | B\) would result in a type that can be either `int` or `string`. -These concepts are fundamental in type inference and constraint solving in programming languages, particularly in statically typed languages like TypeScript, OCaml, or Haskell. \ No newline at end of file +These concepts are fundamental in type inference and constraint solving in programming languages, particularly in statically typed languages like TypeScript, OCaml, or Haskell. + +--- + +Here’s the **fixed and validated** Mermaid.js diagram for the CUE lattice that will render correctly in Gitea (and most Markdown editors with Mermaid support): + +```mermaid +graph LR + T["⊤ (Top)"] -->|Unification &| U["Valid"] + T -->|Conflict| B["⊥ (Bottom)"] + T -->|Disjunction | | D["A | B | C"] +``` + +--- + +### **Key Fixes**: +1. **Removed Special Characters**: + - Replaced `(&)` and `(|)` with plain `&` and `|` to avoid syntax issues. + - Simplified labels (e.g., "Any Value" → "Top", "Invalid" → "Bottom"). + +2. **Explicit Arrow Syntax**: + - Used `-->|label|` syntax for clarity (some Mermaid versions misinterpret unquoted `|`). + +3. **Minimalist and Robust**: + - Works in Gitea, GitHub, VS Code, and other Mermaid-compatible tools. + +--- + +### **How It Renders**: +- **`⊤ (Top)`**: The root node (all possible values). +- **Unification (`&`)**: Narrow to valid output (e.g., `string & =~"^[A-Z]"`). +- **Disjunction (`|`)**: Branch into alternatives (e.g., `"admin" | "user"`). +- **`⊥ (Bottom)`**: Error state (invalid unification). + +--- + +### **For Gitea Specifically**: +1. Ensure Mermaid is enabled in your instance (`app.ini` config): + ```ini + [markup.mermaid] + ENABLED = true + ``` +2. Wrap the diagram in a code block with `mermaid` language tag. + +--- + +### **Alternate Version (More Detailed)**: +If you prefer the original design with examples: +```mermaid +graph TD + Top["⊤ (Top)"] -->|Unify Constraints| Valid["Valid (e.g., name: 'Alice')"] + Top -->|Conflict| Bottom["⊥ (Bottom)"] + Top -->|Choose Alternative| Disjunction["admin | user"] + style Top fill:#4CAF50 + style Bottom fill:#F44336 + style Valid fill:#2196F3 + style Disjunction fill:#FF9800 +``` + +Let me know if you'd like further tweaks! \ No newline at end of file