-
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: “shallow” version of compatible-closure-context
#209
Comments
The notion of a compatible closure is a reasonably standard algebraic closure operation. The resulting set is closed under further application of the transformation function. I don't quite see how this operation is a closure operation. A slightly different variant,
[in your terms] is often used to deal with "stack frames" for the compatible closure relative to evaluation. But I don't think we need an operation to generate those. [[ Now as for the actual |
It isn’t (which is why I said I don’t really know what it should be named).
A fair question! I actually do have a nonterminal like your For example, I have a (define-metafunction eff
free-vars : e -> [x ...]
[(free-vars x) [x]]
[(free-vars (λv x e))
,(remq (term x) (term (free-vars e)))]
[(free-vars (λ x e))
,(remq (term x) (term (free-vars e)))]
[(free-vars (let [x e_1] e_2))
,(remove-duplicates (append (term (free-vars e_1))
(remq (term x) (term (free-vars e_2)))))]
[(free-vars e)
,(let ([recur (term-match eff
[(in-hole S e) (term (free-vars e))])])
(remove-duplicates (append* (recur (term e)))))]) I handle variables and binding forms specially, but the last case is a catch-all “recur everywhere” case implemented using |
Oh you need to think bigger. Since you'd presumably annotate your grammar with Paul's amazing binding annotations, you should demand that in addition to substitute define-language also generates functions such as free-vars. Now you may object that there are other homomorphisms you wish to formulate, not just free-vars because it is unreasonable to have to write out the 38 clauses by hand and it is equally unreasonable to obscure the algorithms with this (cool) trick you used (and I have used, too). It's not like FP hasn't dabbled in these kinds of auto-generated abstractions before (say polytypic programming or general folds and so on). [[ Of course the ultimate objection to abstraction from mathematical oriented readers is that it hurts readability. I think this can be done properly. ]] |
That would certainly also be nice. :)
It would definitely be neat to have a more fit for purpose solution to this problem, but that seems like a much bigger ask than what I’m asking for here, which doesn’t sound very hard to implement (and I was considering possibly opening a PR at some point to do so).
I think that’s a fair criticism, but in this case I have no intention of actually typesetting these metafunctions—I’m just using Redex to explore some ideas on my own. It seems overly conservative to avoid adding any features to Redex that are difficult to read when typeset if they still provide value for other use cases. |
Imagine Racket before for/ and friends. |
I would like a slight variant of
compatible-closure-context
that is “shallow” instead of recursive. This is best explained by example. Consider the following language:Currently, the pattern
(compatible-closure-context e)
is equivalent to the patternC
. However, I would like Redex to be able to instead generate the patternS
. I don’t understand the terminology well enough to suggest a name for such a pattern, but it seems straightforward to implement, since it’s really just a small variant oncompatible-closure-context
.The text was updated successfully, but these errors were encountered: