[GHC] #5324: Locally-scoped RULES
GHC
cvs-ghc at haskell.org
Fri Jul 15 06:21:24 CEST 2011
#5324: Locally-scoped RULES
---------------------------------+------------------------------------------
Reporter: reinerp | Owner:
Type: feature request | Status: new
Priority: normal | Component: Compiler
Version: 7.0.3 | Keywords:
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
I'd like the following to compile:
{{{
module A where
f = g where
{-# RULES "g/h" g = h #-}
g = undefined
h = undefined
}}}
This doesn't currently compile, because all RULES have to be top-level.
However, GHC permits SPECIALISE pragmas at local scope; the following
compiles:
{{{
module Test where
f :: Num a => a -> a
f = g where
{-# SPECIALISE g :: Int -> Int #-}
g :: Num b => b -> b
g x = x + x
}}}
(Admittedly, this example discards the specialisation, but more
interesting examples don't.)
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.
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.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5324>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list