
27 May
2008
27 May
'08
5 p.m.
Hi, I'm trying to find out how the GHC rewrite rules pragma work, but I'm not able to make it working. I have this simple example, where I would like to specialize the function gen to spec on strings: {-# OPTIONS -O2 -fglasgow-exts #-} gen :: [a] -> a gen = head {-# RULES "gen/Char" gen=spec #-} spec :: [Char] -> Char spec x = 'x' main :: IO () main = putStr (gen "aaa":"\n") -- EOF I compile it as: ghc -O2 -fglasgow-exts spec.hs but as a result, is always prints 'a' while I expect 'x'. Is it right? What is the problem here? I would be glad for any answer. I'm using GHC 6.8.2. Sincerely, Jan.