
HI all, I'm having an look at rewrite rules, but something bugs me a little. How do I tell if my rewrite rules are firing or not? Even If I introduce deliberate errors in the function name that is being re-written I still don't get so much as a warning. Clues? Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/

Could be I'm misunderstanding, but are you looking for -ddump-rule-firings?
On Thu, Jan 12, 2017 at 10:46 AM, Erik de Castro Lopo
HI all,
I'm having an look at rewrite rules, but something bugs me a little. How do I tell if my rewrite rules are firing or not? Even If I introduce deliberate errors in the function name that is being re-written I still don't get so much as a warning.
Clues?
Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users

Michael Snoyman wrote:
Could be I'm misunderstanding, but are you looking for -ddump-rule-firings?
Wasn't aware of that, but my question was a little more general. If I write a library that includes rewrite rules, how can I ensure that they fire in client code that someone else writes? What guarantees (however loose) are there? Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/

Hi, Am Freitag, den 13.01.2017, 20:27 +1100 schrieb Erik de Castro Lopo:
Michael Snoyman wrote:
Could be I'm misunderstanding, but are you looking for -ddump-rule- firings?
Wasn't aware of that, but my question was a little more general.
If I write a library that includes rewrite rules, how can I ensure that they fire in client code that someone else writes? What guarantees (however loose) are there?
very little. The best one can do right now is to know enough about Core and the inliner to predict when things are going to be inlined and when not, what else can go wrong (wrappers maybe?), add the necessary controls (`NOINLINE [0]` etc.), and then hope for the best. And track down any instances of failed rewriting that you learn about. You might also be able to set up your code so that it fails (at runtime, with error) if the desired rules did not fire. This would be nicer if we had https://ghc.haskell.org/trac/ghc/ticket/9180. You can also ask for review if it is public code. Greetings, Joachim -- Joachim “nomeata” Breitner mail@joachim-breitner.de • https://www.joachim-breitner.de/ XMPP: nomeata@joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F Debian Developer: nomeata@debian.org

Joachim Breitner wrote:
very little. The best one can do right now is to know enough about Core and the inliner to predict when things are going to be inlined and when not, what else can go wrong (wrappers maybe?), add the necessary controls (`NOINLINE [0]` etc.), and then hope for the best. And track down any instances of failed rewriting that you learn about.
You might also be able to set up your code so that it fails (at runtime, with error) if the desired rules did not fire. This would be nicer if we had https://ghc.haskell.org/trac/ghc/ticket/9180.
You can also ask for review if it is public code.
Ok, I'm heading in this direction and then I figure out that the parser for the rewrite rules doesn't even reject obvious syntax errors. Say I have a data types: data Word128 = Word128 Word64 Word64 and inspired by the `fromIntegral` rules for Word64 I write: {-# RULES "fromIntegral/Word64->Word128" fromIntegral = \w64 -> Word128 0 w64 #-} all is fine and dandy. However if I introduce an obvious syntax error like reversing the `->`: {-# RULES "fromIntegral/Word64<-Word128" fromIntegral = \w64 -> Word128 0 w64 #-} I don't get any warning or anything. I've read the docs for rewrite rules: https://downloads.haskell.org/~ghc/8.0.1/docs/html/users_guide/glasgow_exts.... but they are rather sparse and again are very short on guarantees. Have I just managed to find myself a new project? Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/
participants (3)
-
Erik de Castro Lopo
-
Joachim Breitner
-
Michael Snoyman