Simon Peyton-Jones wrote:
>
> Hmm. Your example relies on inlining 'arr' at its call site.
> My guess is that you aren't using -O. In that case, there's no
> cross-module inlining, so 'arr' doesn't get inlined.
>
> Is that it?
No:
[kevina@kevins-linux Rules]$ make clean
rm -f *.o *.hi
[kevina@kevins-linux Rules]$ make
ghc -c T2.hs -fglasgow-exts -O
ghc: module version changed to 1; reason: no old .hi file
ghc -c Main.hs -fglasgow-exts -O
ghc: module version changed to 1; reason: no old .hi file
rm -f main
ghc -o main -fglasgow-exts -O Main.o T2.o
[kevina@kevins-linux Rules]$ ./main
Fail: In Replace Many
An INLINE arr did not help either.
--
Kevin Atkinson
[EMAIL PROTECTED]
http://metalab.unc.edu/kevina/
module Main where
import T2
arr2 s l = arr s (map (\(i,e)->(i+2,e)) l)
main = print$ arr2 10 [(1::Int,10::Int),(2,20)]
module T2 where
data Arr ix el = Arr Int [(ix,el)] deriving Show
replaceMany :: [(ix,el)] -> Arr ix el -> Arr ix el
replaceMany = error "In Replace Many"
{-# RULES
"rule1" forall f,l,a. replaceMany (map f l) a = replaceManyMap f l a
#-}
replaceManyMap :: (v -> (ix,el)) -> [(ix,el)] -> Arr ix el -> Arr ix el
replaceManyMap = error "In Replace Many Map"
{-# INLINE arr #-}
arr s l =
let a = Arr s [] in
replaceMany l a
HC = ghc
HC_OPTS = -fglasgow-exts $(EXTRA_HC_OPTS)
EXTRA_HC_OPTS = -O
SRCS = $(wildcard *.hs)
OBJ2 = $(SRCS:.hs=.o)
OBJS = $(OBJ2:.lhs=.o)
.SUFFIXES : .o .hi .lhs .hc .s
main : $(OBJS)
rm -f $@
$(HC) -o $@ $(HC_OPTS) $(OBJS)
clean :
rm -f *.o *.hi
realclean: clean
rm -f main main.* core
depend :
mkdependHS -- $(HC_OPTS) -- $(SRCS)
# Standard suffix rules
%.hi : %.o
@:
%.o : %.hs
$(HC) -c $< $(HC_OPTS)
%.o : %.lhs
$(HC) -c $< $(HC_OPTS)
# DO NOT DELETE: Beginning of Haskell dependencies
Main.o : Main.hs
Main.o : ./T2.hi
T2.o : T2.hs
# DO NOT DELETE: End of Haskell dependencies