I was playing around with rules and I got some unexpected results. By
just moving some stuff into a separate module I got different results.
Could some one explain to me while this program:
module Main 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"
arr s l =
let a = Arr s [] in
replaceMany l a
arr2 s l =
arr s (map (\(i,e)->(i+2,e)) l)
main = print$ arr2 10 [(1::Int,10::Int),(2,20)]
produces "Fail: In Replace Many Map" as expected but:
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"
arr s l =
let a = Arr s [] in
replaceMany l a
produces "Fail: In Replace Many"?
And how to fix the problem.
Thanks in advance.
--
Kevin Atkinson
[EMAIL PROTECTED]
http://metalab.unc.edu/kevina/