Stage restriction differs between untyped and typed TH
File:
{-# LANGUAGE TemplateHaskell, TypeApplications #-}
module M where
data T
x = $(const @_ @T [| 'a' |] undefined)
y = $$(const @_ @T [|| 'a' ||] undefined)
x
is rejected:
• GHC stage restriction:
‘T’ is used in a top-level splice, quasi-quote, or annotation,
and must be imported, not defined locally
But y
is accepted. Is there any reason why untyped and typed TH behave differently?
I don't have any example where this actually goes wrong. If there's a reason, it might be added to the documentation.