<div dir="ltr">It seems to be the case that <code>SPECIALIZE</code> pragmas are syntactically restricted to type specializations of a <em>name</em>
(identifier) rather than a general expression. Is my understanding
correct here? If so, is there any reason for this restriction?
<p>I ask because I’m reifying Core code (into code that constructs a
corresponding run-time representation for further processing), and I’m
looking for a clean way to integrate that process with GHC, to support
separate compilation and to avoid interfering with GHC’s regular flow.
It occurred to me that I could enable separate compilation via a pragma
of the form “<code>{-# SPECIALIZE reify foo ∷ E t #-}</code>” for some <code>t</code>, where <code>E t</code> is a reified form of values of type <code>t</code>. Type checking would infer the specialized type of <code>foo</code>, and the usual specialization phase would do its usual thing on that specialization, leaving “<code>reify foo = reify specialized_foo</code>”, and then the reification compiler plugin would transform the right-hand side, pushing the <code>reify</code> inward. Some <code>reify</code>
calls may remain (e.g., due to polymorphism), triggering future rule
applications. As much as possible of the fully-reified version would be
factored out of the generated rule’s RHS for cheap reuse.</p><p><br></p><p>Thanks, - Conal
</p></div>