Inconsistent treatment of unsupported language features in L.H.TH.Desugar.Sweeten
RyanGlScott opened this issue · comments
In most parts of th-desugar
, any code that deals with an unsupported language feature will simply throw an error. Here is an example from L.H.TH.Desugar.Core
:
th-desugar/Language/Haskell/TH/Desugar/Core.hs
Lines 609 to 610 in 67750a0
And from L.H.TH.Desugar.Sweeten
:
th-desugar/Language/Haskell/TH/Desugar/Sweeten.hs
Lines 59 to 61 in 67750a0
However, this convention is not applied uniformly in L.H.TH.Desugar.Sweeten
. There is one particular function, pragmaToTH
, that returns a Maybe
rather than erroring out on unsupported language features:
th-desugar/Language/Haskell/TH/Desugar/Sweeten.hs
Lines 380 to 384 in 67750a0
This has a ripple effect on several other type signatures in L.H.TH.Desugar.Sweeten
. For instance, the type of decToTH
is DDec -> [Dec]
instead the more sensible DDec -> Dec
.
I propose that we change pragmaToTH
to error out on unsupported pragmas, which would allow simplifying its type to DPragma -> Pragma
, enabling other simplifications elsewhere in the module.