Update tech_docs/CUE_your_new_friend.md

This commit is contained in:
2025-08-06 09:34:08 -05:00
parent dbcaee88c5
commit 99b60bc9f1

View File

@@ -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 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`. - **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. These concepts are fundamental in type inference and constraint solving in programming languages, particularly in statically typed languages like TypeScript, OCaml, or Haskell.
---
Heres 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!