GHC: Ticket #5324: Locally-scoped RULES
http://ghc.haskell.org/trac/ghc/ticket/5324
<p>
I'd like the following to compile:
</p>
<pre class="wiki">module A where
f = g where
{-# RULES "g/h" g = h #-}
g = undefined
h = undefined
</pre><p>
This doesn't currently compile, because all RULES have to be top-level.
</p>
<p>
However, GHC permits SPECIALISE pragmas at local scope; the following compiles:
</p>
<pre class="wiki">module Test where
f :: Num a => a -> a
f = g where
{-# SPECIALISE g :: Int -> Int #-}
g :: Num b => b -> b
g x = x + x
</pre><p>
(Admittedly, this example discards the specialisation, but more interesting examples don't.)
</p>
<p>
I only point out that the SPECIALISE pragma succeeds, because the user manual has the comment that rules subsume the 'Obsolete SPECIALIZE syntax', but in this case they don't.
</p>
<p>
I've got a real example where I would like locally-scoped RULES, but it is rather long, so I will post it as a comment.
</p>
en-usGHChttp://ghc.haskell.org/trac/ghc/chrome/site/ghc_logo.png
http://ghc.haskell.org/trac/ghc/ticket/5324
Trac 1.0.9reinerpFri, 15 Jul 2011 04:47:05 GMT
http://ghc.haskell.org/trac/ghc/ticket/5324#comment:1
http://ghc.haskell.org/trac/ghc/ticket/5324#comment:1
<p>
I was writing up my real example, but I just came up with a workaround, so this ticket isn't of such importance to me now.
</p>
TicketiglooSun, 17 Jul 2011 13:42:23 GMTmilestone set
http://ghc.haskell.org/trac/ghc/ticket/5324#comment:2
http://ghc.haskell.org/trac/ghc/ticket/5324#comment:2
<ul>
<li><strong>milestone</strong>
set to <em>7.4.1</em>
</li>
</ul>
<p>
Thanks for the suggestion.
</p>
TicketsimonpjWed, 27 Jul 2011 06:19:39 GMTmilestone changed
http://ghc.haskell.org/trac/ghc/ticket/5324#comment:3
http://ghc.haskell.org/trac/ghc/ticket/5324#comment:3
<ul>
<li><strong>milestone</strong>
changed from <em>7.4.1</em> to <em>_|_</em>
</li>
</ul>
<p>
OK. It's a reasonable request, and there's no technical reason it can't be done, but it's a bit fiddly, so I'll postpone until someone really wants it.
</p>
Ticket