<div dir="ltr"><div>Thanks for the reply, Ed.</div><div><br></div><div>> I'd assume that `x` didn't occur in either `u` or `v`</div><div><br></div><div>This is exactly the issue I'm wondering about. Since rewrite rules admit lambdas and only first-order matching, I'm wondering whether they're interpreted as you did (and I'd tend to), namely that `x` doesn't occur freely in `u`or `v`, in which case lambdas don't seem useful in rules (and yet were implemented for some reason) or they're interpreted as allowing `x` in `u` and `v`, and substitution captures. I'm still puzzled.</div><div><div><br></div><div>With a wee bit of higher-order matching, one might make `u` and `v` functions and instead write:</div><div><br></div><div>> foo (\ x -> fmap (u x) (v x)) = bar u v</div><div><br></div><div>In that case I'd expect `u` and `v` to be synthesized rather than literally matched. For instance, `foo (\ (a,b) -> fmap (+ a) [b,b,b])` would match with `u = \ (a,b) -> (+ a)` and `v = \ (a,b) -> [b,b,b]`.</div></div><div><br></div><div>-- Conal</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Dec 2, 2017 at 12:20 PM, Edward Kmett <span dir="ltr"><<a href="mailto:ekmett@gmail.com" target="_blank">ekmett@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I don't knw of a formal writeup anywhere.</div><div><br></div>But does that actually mean what you are trying to write?<div><br></div><div>With the effective placement of "forall" quantifiers on the outside for u and v I'd assume that x didn't occur in either u or v. Effectively you have some scope like forall u v. exists x. ... </div><div><br></div><div>Under that view, the warnings are accurate, and the rewrite is pretty purely syntactic.</div><div><br></div><div>I don't see how we could write using our current vocabulary that which you want.</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Sun, Dec 3, 2017 at 4:50 AM, Conal Elliott <span dir="ltr"><<a href="mailto:conal@conal.net" target="_blank">conal@conal.net</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div><div><div>Is there a written explanation and/or examples of rewrite rules involving a LHS lambda? Since rule matching is first-order, I'm wondering how terms with lambda are matched on the LHS and substituted into on the RHS. For instance, I want to restructure a lambda term as follows:</div><div><br></div><div>> foo (\ x -> fmap u v) = bar (\ x -> u) (\ x -> v)</div><div><br></div><div>My intent is that the terms `u` and `v` may contain `x` and that whatever variable name is actually used in a term being rewritten is preserved so as to re-capture its occurrences on the RHS.</div><div><br></div><div>When I write this sort of rule, I get warnings about `x` being defined but not used.</div></div></div><div><br></div><div>Thanks,  -- Conal</div></div>
<br></div></div>______________________________<wbr>_________________<br>
Glasgow-haskell-users mailing list<br>
<a href="mailto:Glasgow-haskell-users@haskell.org" target="_blank">Glasgow-haskell-users@haskell.<wbr>org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bi<wbr>n/mailman/listinfo/glasgow-has<wbr>kell-users</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>