惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Apple Machine Learning Research
Apple Machine Learning Research
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 司徒正美
博客园_首页
博客园 - 叶小钗
Blog — PlanetScale
Blog — PlanetScale
The Cloudflare Blog
量子位
人人都是产品经理
人人都是产品经理
小众软件
小众软件
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
Attack and Defense Labs
Attack and Defense Labs
Hacker News: Ask HN
Hacker News: Ask HN
TaoSecurity Blog
TaoSecurity Blog
Forbes - Security
Forbes - Security
罗磊的独立博客
Webroot Blog
Webroot Blog
美团技术团队
Help Net Security
Help Net Security
Google DeepMind News
Google DeepMind News
博客园 - 三生石上(FineUI控件)
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
H
Heimdal Security Blog
C
Check Point Blog
V2EX - 技术
V2EX - 技术
The Last Watchdog
The Last Watchdog
Microsoft Azure Blog
Microsoft Azure Blog
AI
AI
Cloudbric
Cloudbric
Application and Cybersecurity Blog
Application and Cybersecurity Blog
W
WeLiveSecurity
P
Privacy International News Feed
T
The Exploit Database - CXSecurity.com
P
Privacy & Cybersecurity Law Blog
B
Blog RSS Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
L
LINUX DO - 热门话题
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
A
Arctic Wolf
O
OpenAI News
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 【当耐特】
C
Cyber Attacks, Cyber Crime and Cyber Security
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Y
Y Combinator Blog
Know Your Adversary
Know Your Adversary

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
CLAUDE.md for Haskell: 13 Rules That Make AI Write Idiomatic, Type-Safe Haskell
Olivia Craft · 2026-05-15 · via DEV Community

Haskell has the largest gap between code that compiles and code that's actually idiomatic of any mainstream language. The type system is powerful enough that AI can generate Haskell that type-checks but uses head on empty lists, catches errors with error "", and avoids the very abstractions that make Haskell valuable.

A CLAUDE.md at your project root tells the AI which Haskell you're writing. Here are 13 rules with the highest impact.


Rule 1: GHC version and language extensions

GHC version: 9.6+ (GHC2021 language set or explicit extensions).
Enable these extensions in package.yaml or cabal file (not per-file pragmas except for unusual cases):
  OverloadedStrings, ScopedTypeVariables, LambdaCase, TupleSections,
  DeriveFunctor, DeriveGeneric, GeneralizedNewtypeDeriving,
  FlexibleInstances, FlexibleContexts

Do NOT enable: PartialTypeSignatures (forces you to complete type signatures).
Do NOT use extensions that enable unsafe operations unless documented.

Enter fullscreen mode Exit fullscreen mode

GHC's language extension system is powerful but needs explicit guidance. AI sometimes adds extensions ad-hoc or omits ones that would enable cleaner code.


Rule 2: No partial functions — totality is the goal

Partial functions are banned:
- Never use `head`, `tail`, `init`, `last` — use pattern matching or `NonEmpty`
- Never use `fromJust` — use `maybe`, `fromMaybe`, or pattern match
- Never use `read` on untrusted input — use `readMaybe` from `Text.Read`
- Never use `error` for recoverable failures — use `Either` or `ExceptT`
- Never use `undefined` except as a temporary compile placeholder with a TODO comment

Prefer total alternatives:
  `headMay`, `atMay` from the `safe` package, or pattern matching.

Enter fullscreen mode Exit fullscreen mode

Partial functions are the #1 source of runtime crashes in Haskell. head [] throws an exception that the type system didn't catch. AI uses partial functions because they're shorter and common in tutorials.


Rule 3: Maybe and Either — explicit absence and failure

Absence and failure:
- `Maybe a` for values that may not exist
- `Either e a` for operations that can fail with an error
- `ExceptT e m a` for monadic computations that can fail
- `MaybeT m a` for monadic computations that may produce nothing

Chain with `>>=`, `<$>`, `<*>`, `maybe`, `either`, `fromMaybe`.
Never throw exceptions for business logic — use `Left err`.

For error types: define a sum type, not `String`:
  `data AppError = NotFound Text | InvalidInput Text | DatabaseError Text`

Enter fullscreen mode Exit fullscreen mode

error "something went wrong" is Haskell's equivalent of unchecked exceptions. The type system is there to make errors explicit — use it.


Rule 4: Type signatures on all top-level definitions

Every top-level function and value must have an explicit type signature:
  `processUser :: UserId -> IO (Either AppError User)` — not inferred.

Type signatures serve as:
- Documentation (the primary kind)
- Compiler-checked contracts
- Guidance for type inference in complex expressions

Use `newtype` for type safety around primitives:
  `newtype UserId = UserId { unUserId :: Int } deriving (Show, Eq, Ord)`
  Not: `type UserId = Int` (type aliases provide no safety)

Enter fullscreen mode Exit fullscreen mode

Type inference is powerful but type signatures are still mandatory for top-level definitions. AI sometimes omits them to save space — they're not optional.


Rule 5: Pattern matching — exhaustive and expressive

Pattern matching rules:
- Always handle all constructors — enable `-Wincomplete-patterns` in GHC options
- Use `LambdaCase` for concise single-argument matches:
    `\case { Just x -> ...; Nothing -> ... }`
- Deconstruct in function arguments, not in the body:
    `processUser (User uid name) = ...` not `processUser u = let uid = userId u in ...`
- Use `@` patterns to bind the whole value while matching: `processUser u@(User uid _) = ...`
- Wildcards `_` only when the value is genuinely unused

Enter fullscreen mode Exit fullscreen mode

Exhaustive pattern matching with compiler warnings turns runtime errors into compile errors. AI often uses incomplete patterns or reaches for field accessors where destructuring is cleaner.


Rule 6: Functors, Applicatives, Monads — use the right abstraction

Abstraction selection:
- `fmap` / `<$>` when transforming a value inside a context (Functor)
- `<*>` when applying a wrapped function to a wrapped value (Applicative)
- `>>=` / `do` notation for sequential effects where each step depends on the previous (Monad)
- `traverse` for `t a -> (a -> f b) -> f (t b)` (effects over a traversable)
- `sequence` for `t (f a) -> f (t a)`

Prefer `do` notation for readability when there are 3+ monadic steps.
Prefer point-free style for simple compositions: `f . g . h` not `\x -> f (g (h x))`.

Enter fullscreen mode Exit fullscreen mode

The Functor/Applicative/Monad hierarchy exists to express precisely how much power you need. AI often reaches for Monad/do when Applicative or fmap is sufficient — the less powerful abstraction is usually clearer.


Rule 7: Text, not String

String handling:
- Use `Text` (from `Data.Text`) everywhere, not `String` ([Char])
- Enable `OverloadedStrings` so string literals work as `Text`
- Use `Data.Text.pack`/`unpack` only at system boundaries (IO, legacy APIs)
- For building text: `Data.Text.Builder` or `fmt` library — not `++` concatenation
- For parsing: `attoparsec` or `megaparsec` — not manual `String` manipulation
- ByteString for binary data — never treat `ByteString` as text

Enter fullscreen mode Exit fullscreen mode

String = [Char] is a linked list of characters. It's the default for historical reasons and is terrible for performance. Text is the correct type for textual data. AI uses String because tutorials use String.


Rule 8: Records and lenses

Record conventions:
- Use record syntax for data types with multiple fields
- Prefix field names with the type name to avoid ambiguity:
    `data User = User { userId :: UserId, userName :: Text, userEmail :: Email }`
- Use `lens` or `optics` for nested record access/update
- Avoid the `RecordWildCards` extension — it makes imports invisible
- For large records: use `Generic` + `lens` derivation

When using lenses:
  `user ^. userName` not `userName user`
  `user & userName .~ "Alice"` not `user { userName = "Alice" }`

Enter fullscreen mode Exit fullscreen mode

Record field names in Haskell pollute the module namespace without prefixing. Lenses provide composable access and update for nested data.


Rule 9: IO and effects — keep pure code pure

Effect discipline:
- Maximize pure functions — if it doesn't need IO, don't put it in IO
- Use `ReaderT env IO` as the application monad (not raw IO or a complex mtl stack)
- Keep the `IO` boundary at the edges: parse input, process purely, render output
- Use `IORef` only when mutation is genuinely required (rare)
- For config: pass explicit records, not global IORef or unsafePerformIO

For concurrent code: use `async` + `stm` (Software Transactional Memory).
Never use `unsafePerformIO` outside of FFI boundaries.

Enter fullscreen mode Exit fullscreen mode

"IO everywhere" is a beginner pattern. Pure functions are easier to test, reason about, and compose. The discipline of keeping IO at the edges is one of Haskell's greatest design patterns.


Rule 10: Testing with Hspec and QuickCheck

Testing:
- Hspec for unit and integration tests (BDD-style: `describe`/`it`/`shouldBe`)
- QuickCheck for property-based testing — generate invariants, not just examples
- `hspec-discover` for automatic spec discovery
- Test pure functions without IO — makes tests fast and deterministic
- For IO: use `hspec` with `before`/`after` for setup/teardown
- Golden tests: `hspec-golden` for output comparison

Property patterns to always write:
  roundtrip: `encode . decode = id`
  idempotence: `f (f x) = f x`
  commutativity where applicable

Enter fullscreen mode Exit fullscreen mode

QuickCheck is one of Haskell's most valuable tools and is underused in AI-generated test suites. Property-based tests catch edge cases that example-based tests miss by definition.


Rule 11: Cabal/Stack and dependency management

Build system: Cabal with cabal.project, or Stack with stack.yaml — pick one and be consistent.

cabal conventions:
- Pin GHC version in cabal.project: `with-compiler: ghc-9.6.x`
- Use `cabal freeze` for reproducible builds
- Separate library, executable, and test stanzas in .cabal file
- Enable warnings in all stanzas: `-Wall -Wcompat -Widentities`

HLS (Haskell Language Server): configure in hie.yaml for IDE support.
Do NOT use `cabal install` globally — use `cabal run` or add to PATH via nix/ghcup.

Enter fullscreen mode Exit fullscreen mode


Rule 12: Deriving and Generic

Use `deriving` to avoid boilerplate:
  `deriving (Show, Eq, Ord, Generic)`

For JSON: use `aeson` with Generic derivation:
  `instance ToJSON User; instance FromJSON User` — no manual instances unless customizing.

For other typeclasses: prefer `deriving` via `GeneralizedNewtypeDeriving` or `DerivingVia`.

Do NOT write manual `Show` instances unless the output format is specifically required.
Do NOT write manual `Eq` instances unless the equality semantics differ from structural equality.

Enter fullscreen mode Exit fullscreen mode

Boilerplate Show/Eq/Ord instances are noise. deriving is the correct default. AI sometimes writes them manually.


Rule 13: Haddock and documentation

Documentation:
- All exported functions must have Haddock comments
- Format: `-- | Description. Example: @functionName arg@`
- Document the invariants and preconditions, not the implementation
- Use `@since` tags for API additions
- Run `cabal haddock` to verify documentation builds

Module exports: explicit export lists on all modules — no `module Foo where` without an export list.
Explicit exports make the API surface clear and prevent accidental exports.

Enter fullscreen mode Exit fullscreen mode


Your CLAUDE.md starting point

# Haskell Project — AI Coding Rules

## Safety
No partial functions: no head/tail/fromJust/read/error/undefined.
Use Maybe/Either/ExceptT for absence and failure. Total functions only.

## Types
Explicit type signatures on all top-level definitions.
newtype over type aliases for domain types.
Text not String. OverloadedStrings enabled.

## Style
Exhaustive pattern matching (-Wincomplete-patterns enforced).
LambdaCase for single-argument matches.
Pure functions maximized — IO only at edges.
ReaderT env IO as application monad.

## Abstractions
Use fmap/Applicative when Monad is not needed.
traverse for effects over traversables.
Point-free for simple compositions.

## Records
Prefix field names with type name. lens/optics for nested access.

## Testing
Hspec + QuickCheck. Properties: roundtrip, idempotence. Pure functions tested without IO.

## Build
GHC 9.6+. -Wall -Wcompat -Wincomplete-patterns. Explicit export lists on all modules.

Enter fullscreen mode Exit fullscreen mode


Why Haskell especially needs this

Haskell's type system can catch an enormous class of bugs at compile time — but only if you use it correctly. Partial functions, String instead of Text, and avoiding the abstraction hierarchy all leave power on the table.

CLAUDE.md is the difference between AI that uses Haskell and AI that uses Haskell well.

The full rules pack across 15+ languages is at gumroad — $27.