Introducing checked-literals: compile-time bounds checking for numeric literals
GHC’s builtin overflow warnings are easy to bypass and don’t work for custom numeric types. We wrote a GHC source plugin,
checked-literals, that rewrites numeric literals so that out-of-range values are rejected at compile time. It works in monomorphic and polymorphic contexts, supports integer and rational literals, and produces actionable error messages – including suggested type-level constraints.