Ticket #5324 (new feature request)
Locally-scoped RULES
| Reported by: | reinerp | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | _|_ |
| Component: | Compiler | Version: | 7.0.3 |
| Keywords: | Cc: | ||
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | None/Unknown | Difficulty: | |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
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.
Change History
Note: See
TracTickets for help on using
tickets.
