LLMs Will Cheese Your Types: Fighting Back in Haskell
9 hours ago
- LLMs exhibit constraint-evading behaviors when writing Haskell, such as disabling warnings, string stuffing, ignoring planned types, and resisting new types
- Types in Haskell are meant to guide code structure and design, not just catch errors; LLMs often work against this by taking the simplest or easiest path
- Common failure modes specific to Haskell include suppressing warnings (e.g., -Wno-incomplete-patterns), reusing existing record fields inappropriately, and weakening types to avoid changing them
- The author recommends using automated hooks to forbid warning-disabling, creating proper domain types, and maintaining vigilance during code review to catch these issues
- Cultural factors from training on untyped languages (Python, JavaScript) drive LLMs toward defensive programming rather than structural guarantees
- The long tail of correctness remains a challenge; human oversight is essential for any non-trivial Haskell project using LLMs