proomt

Search

Search posts, papers, and topics

Hall of Fame

Hall of FameAlexis King201918 min readintermediate

Parse, Don't Validate

Summary

The post argues for “parse, don’t validate”: instead of checking inputs and discarding the information, convert them into richer types that encode the validation result. Using Haskell’s NonEmpty type turns a partial head function into a total one, eliminating redundant runtime checks and catching bugs at compile time.

  • Use richer input types (e.g., NonEmpty) to encode invariants rather than returning Maybe and handling impossible cases later.
  • Turning a partial function into a total one by strengthening argument types removes redundant checks and improves compile‑time safety.
  • Parsing functions return refined types that preserve proof of validation, while validate‑only functions lose that information.
  • Compose parsing with existing functions (e.g., head' = fmap head . nonEmpty) to bridge between old and new APIs.

Static‑typed developers should care because encoding invariants in types prevents runtime errors and unnecessary boilerplate.

6/10

Related reading

  1. Eliminating AI Code Hallucinations with TypeScript Compiler Diagnostics and TDD Loops

    The article shows how to replace raw TypeScript compiler output with a programmatic JSON feedback loop that merges diagnostics and Vitest test failures, feeding the structured data back to an LLM coding agent for self‑correction. It provides concrete code for extracting, enriching, validating, and de‑duplicating errors, and demonstrates token savings and deterministic iteration until compilation…

    SitePointsitepoint.com15 min
  2. Constraint Decay: The Fragility of LLM Agents in Backend Code Generation

    A systematic evaluation of LLM agents generating multi‑file backend code shows a sharp drop in correctness when structural constraints (framework conventions, ORM usage, API contracts) are added. Across 100 tasks in 8 Python web frameworks, assertion pass rates fall ~27 points, with data‑layer bugs (bad queries, ORM violations) driving most failures. Mid‑size models cope with minimal frameworks (…

    arXiv cs.SE (Software Engineering)arxiv.org1 minpaperHN287197
  3. How to Write with an LLM

    The post proposes a two‑rule workflow for using LLMs as copy‑editors rather than ghostwriters: never adopt a phrase the model suggests, and block its encouragement feedback. It then shows how to automate iterative copy‑editing with a small Python/HTMX/Tailwind app and a set of concrete prompts.

    Hacker News front pagesockpuppet.org6 minHN712401
  4. Immutability in PHP Beyond readonly

    The article walks through practical ways to achieve immutability in PHP beyond the built‑in readonly keyword, covering interior mutability, immutable value objects, collections, dates, and cloning. It also shows how to enforce and test these patterns in real codebases.

    Freek Van der Hertenfreek.dev1 min
  5. Build Hints That Fail Before the Build Server

    Codename One moved 87 common build hints into Java annotations, so misspelled keys or wrong value types cause compile‑time errors instead of silent build‑server ignores. The annotations are processed back into the existing string protocol, keeping backward compatibility while improving validation and IDE support.

    CodeName Onecodenameone.com6 min