goldfirere / singletons

Fake dependent types in Haskell using singletons
286 stars 36 forks source link

Remove special-casing when singling `error` and friends #597

Closed RyanGlScott closed 3 months ago

RyanGlScott commented 4 months ago

Previously, singExp had a number of ad hoc special cases for handling functions that look like exceptions (e.g., sError and sUndefined). This was because their return types are a rather than, say, Sing (Undefined @a), which impaired GHC's ability to typecheck singletons-th–generated code. As discussed in #588, however, there doesn't appear to be any good reason for these functions to have return types that are so polymorphic, which called into question why we are maintained these ad hoc special cases in the first place.

This patch removes the special casing and gives sError, sErrorWithoutStackTrace, and sUndefined less polymorphic return types. The upshot is that I was able to delete a fair bit of ugly code from D.S.TH.Single, which is a nice payoff.

Fixes #588.