<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">&gt; Why don&#39;t the rules fire,</div><div class="im">
<br>
</div>Because the &#39;match&#39; is at the wrong type.</blockquote><div><br></div><div>This was the correct hint, thanks!</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">&gt; what can I change such that they do,<br>
<br>
</div>Type signatures.<br></blockquote><div><br></div><div>Initially, I thought that just leaving out the polymorphic signature should fix the problem. But I think it cannot be fixed by changing type signatures only because once the type of `g` in the rule is fixed, the rule is no longer type correct!</div>
<div><br></div><div>To overcome this, I have defined</div><div><br></div><div><div>    gen :: (forall m . Monoid m =&gt; (a -&gt; m) -&gt; b -&gt; m) -&gt; b -&gt; [a]</div><div>    gen g = g single</div><div>    {-# NOINLINE gen #-}</div>
</div><div><br></div><div>and changed the rules to</div><div><div><br></div><div>{-# RULES</div><div>  &quot;monoid fusion pointfree&quot;</div><div>    forall f (g :: forall m . Monoid m =&gt; (a -&gt; m) -&gt; b -&gt; m) .</div>
<div>      fold f . gen g = g f;</div><div><br></div><div>  &quot;monoid fusion pointed&quot;</div><div>    forall f (g :: forall m . Monoid m =&gt; (a -&gt; m) -&gt; b -&gt; m) b .</div><div>      fold f (gen g b) = g f b;</div>
<div>  #-}</div></div><div><br></div><div>and now they fire. Seems a bit roundabout but I don&#39;t see how to avoid this indirection.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">&gt; and what to get rid of the warning for the second rule (which I think<br>
&gt; is the one I should use)?<br>
<br>
</div>I&#39;ll let that for somebody else.<br>
</blockquote></div><br><div>My new rules don&#39;t cause this warning. I&#39;m still interested in what the warning meant, although my code does not depend on an answer anymore.</div><div><br></div><div>Probably because, GHC inlines function composition in the first line of</div>
<div><br></div><div><div>    main = do print ((fold id . gen idGen) [[()]])</div><div>              print (fold id (gen idGen [[()]]))</div></div><div><br></div><div>the pointed rule fires twice if I remove the point-free one.</div>
<div><br></div><div>Does it make sense to keep the point-free rule just in case that `fold f . gen g` is passed to a higher-order function and does not get an argument after inlining?</div><div><br></div><div>Sebastian</div>