xiaohongshu
xiaohongshu
collimator
Guide for using Collimator, a profunctor optics library for Lean 4. Use when writing code with lenses, prisms, traversals, or when accessing/modifying nested data structures.
Full skill instructions
Collimator is a profunctor optics library for Lean 4. Optics provide composable, type-safe access patterns for nested data structures.
import Collimator.Prelude -- Core optic types and operations
import Collimator.Operators -- Haskell-style operators
import Collimator.Combinators -- Advanced combinators
import Collimator.Instances -- Instances for List, Option, String
open Collimator
open scoped Collimator.Operators -- Enable operator syntax
| Optic | Focus | Read | Write |
|---|---|---|---|
Iso' s a | Exactly 1 (reversible) | Yes | Yes |
Lens' s a | Exactly 1 | Yes | Yes |
Prism' s a | 0 or 1 (sum types) | Maybe | Yes |
AffineTraversal' s a | 0 or 1 | Maybe | Yes |
Traversal' s a | 0 or more | List | Yes |
data ^. optic -- View (Lens, Iso)
data ^? optic -- Preview optional (Prism, AffineTraversal)
data ^.. optic -- Collect all (Traversal)
data & optic %~ f -- Modify with function
data & optic .~ value -- Set value
structure Person where
name : String
age : Nat
-- Preferred: use fieldLens% macro
def nameLens : Lens' Person String := fieldLens% Person name
inductive JsonValue
| str : String → JsonValue
| num : Int → JsonValue
-- Preferred: use ctorPrism% macro
def strPrism : Prism' JsonValue String := ctorPrism% JsonValue.str
-- For Option.some
def somePrism (α : Type) : Prism' (Option α) α := ctorPrism% Option.some
Optics compose with ∘. Use optic% for type annotations:
-- Lens ∘ Prism = AffineTraversal
let emailAffine := optic%
userProfileLens ∘ somePrism Profile ∘ emailLens
: AffineTraversal' User String
user ^? emailAffine -- Option String
user & emailAffine %~ toUpper -- Modify if present
[-1, 2, -3, 4] & filteredList (· > 0) %~ (· * 2) -- [-1, 4, -3, 8]
[1, 2, 3] ^? _head -- some 1
[1, 2, 3, 4] & taking 2 %~ (· * 10) -- [10, 20, 3, 4]
(3, 5) & both %~ (· * 2) -- (6, 10)
traversed, itraversed, atLens, ixsomePrism' α, traversedchars (Iso), traversed_1, _2xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience