haskell-diagrams
БесплатноБез исполняемых скриптовНе проверенhaskell-diagrams - Declarative Vector Graphics with Diagrams DSL
от plurigrid★ 73 звезды на GitHubОб этом скилле
haskell-diagrams - Declarative Vector Graphics with Diagrams DSL
Overview
Integrates the Haskell diagrams embedded domain-specific language for creating declarative vector graphics. Used for:
- Tsillerson Automata Visualization: 2+1D lattice with vortex/antivortex defects
- Golden Thread Color Spirals: φ-angle (137.508°) color progression
- Path Equivalence Diagrams: Kleppmann-Bumpus-Gay path comparison
- GF(3) Trit Coloring: Triadic conservation visualizations
Trit: +1 (PLUS) - Generates vector graphics artifacts
Core Formula
-- Diagrams is a monoid: composition via <>
diagram :: Diagram B
diagram = shape1 <> shape2 `atop` shape3
-- Transformation pipeline
transform :: Diagram B -> Diagram B
transform = scale 2 . rotate (45 @@ deg) . fc red
Predicates
| Predicate | Description | GF(3) Role |
|---|---|---|
DiagramValid(d) |
Diagram is well-formed | Structure |
ColorConserved(ds) |
Σ trits = 0 across diagrams | Conservation |
PathEquivalent(p1,p2) |
Visual fingerprints match | Equivalence |
GoldenAngle(θ) |
θ ≈ 137.508° | Dispersion |
Architecture
┌────────────────────────────────────────────────────────────────┐
│ Haskell Diagrams Pipeline │
├────────────────────────────────────────────────────────────────┤
│ │
│ Source (.hs) Diagram B Output │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌──────────┐ ┌───────────────────┐ ┌─────────────┐ │
│ │ DSL Code │───▶│ Monoid Compose │───▶│ SVG / PNG │ │
│ │ shapes, │ │ atop, beside, │ │ PDF / PS │ │
│ │ colors │ │ vsep, hsep │ │ Canvas │ │
│ └──────────┘ └───────────────────┘ └─────────────┘ │
│ │
│ Backends: -fsvg (default), -fcairo, -frasterific, -fcanvas │
│ │
└────────────────────────────────────────────────────────────────┘
Triads (GF(3) = 0)
# Diagrams Generation Bundle
three-match (-1) ⊗ haskell-diagrams (0) ⊗ gay-mcp (+1) = 0 ✓ [Core Diagrams]
temporal-coalgebra (-1) ⊗ haskell-diagrams (0) ⊗ topos-generate (+1) = 0 ✓ [Animation]
sheaf-cohomology (-1) ⊗ haskell-diagrams (0) ⊗ rubato-composer (+1) = 0 ✓ [Music Notation]
persistent-homology (-1) ⊗ haskell-diagrams (0) ⊗ gay-mcp (+1) = 0 ✓ [TDA Viz]
Installation
# Install with SVG backend (default)
cabal update && cabal install --lib diagrams diagrams-svg diagrams-contrib
# With cairo backend for PNG/PDF
cabal install gtk2hs-buildtools
cabal install --lib -fcairo diagrams
# With rasterific for Haskell-native PNG
cabal install --lib -frasterific diagrams
Core API
Shapes
import Diagrams.Prelude
-- Basic shapes
circle 1 :: Diagram B
square 2 :: Diagram B
rect 3 4 :: Diagram B
triangle 1 :: Diagram B
pentagon 1 :: Diagram B
-- Paths and trails
fromVertices [p2 (0,0), p2 (1,1), p2 (2,0)]
arc (0 @@ deg) (90 @@ deg)
Composition
-- Monoid: overlay at origin
d1 <> d2
-- Explicit overlay
d1 `atop` d2
-- Spatial arrangement
d1 ||| d2 -- beside horizontally
d1 === d2 -- beside vertically
hcat [d1, d2, d3] -- horizontal list
vcat [d1, d2, d3] -- vertical list
hsep 0.5 [d1, d2] -- with spacing
vsep 0.5 [d1, d2]
Styling
-- Fill and stroke
diagram # fc red -- fill color
diagram # lc blue -- line color
diagram # lw thick -- line width
diagram # opacity 0.5
-- Transforms
diagram # scale 2
diagram # rotate (45 @@ deg)
diagram # translate (r2 (1, 2))
Colors (Gay.jl Integration)
import Data.Colour.SRGB (sRGB24read)
-- Golden thread colors (seed 1069)
goldenThreadColors :: [Colour Double]
goldenThreadColors = map sRGB24read
[ "#DD3C3C", "#3CDD6B", "#9A3CDD" -- steps 1-3
, "#DDC93C", "#3CC2DD", "#DD3C93" -- steps 4-6
, "#64DD3C", "#433CDD", "#DD723C" -- steps 7-9
]
-- GF(3) trit colors
tritColor :: Trit -> Colour Double
tritColor Minus = sRGB24read "#2626D8" -- Blue (validator)
tritColor Zero = sRGB24read "#26D826" -- Green (coordinator)
tritColor Plus = sRGB24read "#D82626" -- Red (generator)
Tsillerson Automata Example
-- Cell state visualization
data CellState = Empty | Vortex | Antivortex | Path0 | Path1 | Path2
cell :: CellState -> Diagram B
cell Empty = square 1 # fc white # lw thin
cell Vortex = circle 0.35 # fc vortexColor <> square 1 # lw thin
cell Antivortex = circle 0.35 # fc antivortexColor <> square 1 # lw thin
cell Path0 = square 0.6 # fc path0Color <> square 1 # l
Установить haskell-diagrams в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл haskell-diagrams?
haskell-diagrams - Declarative Vector Graphics with Diagrams DSL
Как установить скилл haskell-diagrams?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл haskell-diagrams запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic