I compiled that module with GHC 7.0.3, and the rule foldr/fromWrite does fire.  
See below.  Add -ddump-rule-rewrites to see more info.

So can you be more explicit about the problem you see?

Simon

bash-3.1$ ghc -ddump-rule-firings -O Test_RewriteFoldr.hs 
[1 of 1] Compiling Test_RewriteFoldr ( Test_RewriteFoldr.hs, 
Test_RewriteFoldr.o )
Rule fired: unpack
Rule fired: unpack
Rule fired: ++
Rule fired: fold/build
Rule fired: unpack
Rule fired: unpack
Rule fired: ++
Rule fired: fold/build
Rule fired: concat
Rule fired: unpack
Rule fired: ++
Rule fired: fold/build
Rule fired: unpack
Rule fired: ++
Rule fired: fold/build
Rule fired: ++
Rule fired: foldr/fromWrite
Rule fired: Class op mappend
Rule fired: Class op mempty
Rule fired: Class op mappend
Rule fired: Class op mempty
Rule fired: Class op >=
Rule fired: unpack
Rule fired: Class op showsPrec
Rule fired: Class op showsPrec
Rule fired: Class op mconcat
Rule fired: unpack
Rule fired: unpack
Rule fired: unpack
Rule fired: Class op >>
Rule fired: Class op showList
Rule fired: ++
Rule fired: Class op showsPrec
Rule fired: map
Rule fired: fold/build
Rule fired: Class op >>
Rule fired: Class op show
Rule fired: Class op return
Rule fired: unpack-list
Rule fired: unpack-append
Rule fired: unpack-append
Rule fired: unpack-append
Rule fired: foldr/app
Rule fired: unpack-list
Rule fired: foldr/app
Rule fired: unpack-list
Rule fired: unpack-list
Rule fired: unpack-list
bash-3.1$

|  -----Original Message-----
|  From: Simon Meier [mailto:[email protected]]
|  Sent: 14 June 2011 16:48
|  To: Simon Peyton-Jones
|  Cc: [email protected]
|  Subject: Re: Debugging non-firing rewrite rules
|  
|  Hi Simon,
|  
|  the attached module illustrates the problem. I don't think it's a compiler 
bug. Its more
|  that I don't understand the foldr/build fusion framework currently in use 
well-enough.
|  Anyways, I'm very glad for any help.
|  
|  best regards,
|  Simon
|  
|  2011/6/13 Simon Peyton-Jones <[email protected]>:
|  > Any chance you could make a standalone example demonstrating the problem?  
ie
|  one or two modules with suitable definitions, perhaps some stubs. ({-# 
NOINLINE #-}
|  is useful for the stubs.)  Not only does that make it easier to identify 
what's going
|  wrong, but it also means we can add it to the regression suite (if there is 
a bug) to
|  ensure it doesn't happen again.
|  >
|  > Simon
|  >
|  > | -----Original Message-----
|  > | From: [email protected]
|  > | [mailto:[email protected]] On Behalf Of Simon Meier
|  > | Sent: 11 June 2011 14:44
|  > | To: [email protected]
|  > | Subject: Debugging non-firing rewrite rules
|  > |
|  > | Hi,
|  > |
|  > | there's quite some material on how to debug/track rewrite rules that
|  > | do fire. However, I couldn't find information about how to find out
|  > | what is wrong with a rule that supposedly should, but actually
|  > | doesn't fire. Concretely, I would like to add a rewrite rule that
|  > | converts
|  > |
|  > |   mconcat . map (fromWrite w)
|  > |
|  > | to
|  > |
|  > |   fromWriteList w
|  > |
|  > | The relevant definitions and types are:
|  > |
|  > | mconcat = foldr append empty
|  > | append           :: Builder -> Builder -> Builder empty
|  > | :: Builder fromWrite       :: Write a -> a -> Builder fromWriteList
|  > | :: Write a -> [a] -> Builder
|  > |
|  > | The rewrite rule that I tried is
|  > |
|  > | "foldr/fromWrite" forall w.
|  > |      foldr (\x b -> append (fromWrite w x) b) empty = fromWriteList
|  > | w
|  > |
|  > | combined with {-# INLINE [1] #-} anotations on the `append`,
|  > | `empty`, `fromWrite` and `fromWriteList`. However, the rule doesn't
|  > | fire for a definition like
|  > |
|  > | word8s :: [Word8] -> Builder
|  > | word8s = mconcat . map (fromWrite writeWord8)
|  > |
|  > | I suspect that the foldr/build fusion rules are interacting.
|  > | However, I don't know how this interaction looks like. Is there a
|  > | way to track all simplifications of `word8s` in all phases? If there
|  > | was, then I could formulate my rule such that it is reduced with
|  > | respect to the other rewriting rules. Then, the interaction should work 
out.
|  > |
|  > | thanks for your help,
|  > | Simon
|  > |
|  > | PS: The above definitions are part of the builder for the bytestring
|  > | package [1] and my experiment on rule firings can be found here [2].
|  > |
|  > | [1] https://github.com/meiersi/bytestring
|  > | [2]
|  > | https://github.com/meiersi/bytestring/blob/master/tests/builder/Writ
|  > | eListFusion.hs
|  > |
|  > | _______________________________________________
|  > | Cvs-ghc mailing list
|  > | [email protected]
|  > | http://www.haskell.org/mailman/listinfo/cvs-ghc
|  >
|  >

_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to