AI Safety

GHC gains new modifier syntax after 18-month implementation by philh

A solo developer spent 18 months adding modifier syntax to GHC for per-instance UndecidableInstances.

Deep Dive

Developer philh successfully implemented a new modifier syntax in GHC to enable per-instance UndecidableInstances, a feature first proposed in July 2024. The work began in September 2024, with a pull request opened in September 2025 and merged in April 2026—roughly 18 months total, though most hours were concentrated later. The syntax extends GHC's existing `%` modifier notation (used for linear types, e.g., `%One -> b`) to control instance resolution, replacing the old comment-based `{-# UNDECIDABLE #-}` annotations. Key technical hurdles included handling shift/reduce conflicts in the parser (including a temporary `modifiersShift` rule), understanding obscure GHC internals like 'zonking' (a type inference pass) and 'synifying' (converting internal representations to syntax), and dealing with merge conflicts across 60+ files.

The implementation follows the 'trees that grow' pattern, adding a field to record types and letting the compiler guide most of the work via error messages. philh noted that while the GHC codebase lacks consistent formatting—mixing brace and layout style, broken vertical alignment—the project wisely prefers smaller patches over sweeping formatting changes. The new syntax is designed to be more principled than the ad-hoc comment approach, though exact details (semicolon placement, competing modifiers, allowing `type MySynonym = ExistingModifier`) required careful specification. This marks philh's second contribution to GHC, following mentorship at Zurihac 2023.

Key Points
  • philh implemented per-instance UndecidableInstances using a `%` modifier syntax over 18 months (Sept 2024 – Apr 2026).
  • Parser challenges included shift/reduce errors and merging 60+ files with inconsistent formatting.
  • New syntax extends GHC's existing linear types modifier notation, replacing old comment-based annotations like `{-# UNDECIDABLE #-}`.

Why It Matters

Makes Haskell type system more expressive without fragile comments, enabling finer control over instance resolution.

📬 Get the top 10 AI stories daily