<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">> Why don't the rules fire,</div><div class="im">
<br>
</div>Because the 'match' 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">> 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 => (a -> m) -> b -> m) -> b -> [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> "monoid fusion pointfree"</div><div> forall f (g :: forall m . Monoid m => (a -> m) -> b -> m) .</div>
<div> fold f . gen g = g f;</div><div><br></div><div> "monoid fusion pointed"</div><div> forall f (g :: forall m . Monoid m => (a -> m) -> b -> 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'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">> and what to get rid of the warning for the second rule (which I think<br>
> is the one I should use)?<br>
<br>
</div>I'll let that for somebody else.<br>
</blockquote></div><br><div>My new rules don't cause this warning. I'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>