-
Notifications
You must be signed in to change notification settings - Fork 43
Introduce mem-rel! function in builtin_stdlib.elpi #381
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
Open
patrick-nicodemus
wants to merge
1
commit into
LPCIC:master
Choose a base branch
from
patrick-nicodemus:patch-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+5
−2
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit lost, the implementation of
mem-rel! A R Lis literallyexists! L (R A), I don't get what one gains by using the new API.In particular I don't get the example with map and swap. The
{{are the Rocq ones?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I mixed up the notation with Rocq quotation and spilling. I meant spilling. I have edited my comment.
You are probably right, maybe it is not useful. My point is that:
Ais an element of a listL, I can domem! A Lf Ais an element of a listL, I can domem! {f A} LAis an element ofmap g L, my first instinct is to write it asmem! A {map g L}, but this is inefficient.I guess this solution is obvious but I am suggesting that it is a special case of
exists!that could be more commonly used, for example we could definemem! X Lasexists! L (Y\ X = Y)but it has its own namemem!instead.Maybe it would be more useful if
Rwas flipped,something like
so that
mem-map! A G Liffmem! A {map G L}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. In this case I usually prefer the non-cutting (relational) combinators (some of which are not even in elpi stdlib) and write
mem X L, g X Y, !. It is really generate + test (and commit if cut).It seems more of a "style" than an API to me. So I'm happy to add all the APIs to make the style comfortable.
Maybe
generate-test P Qcould be an idiomatic way to express that, but I'm not so sure it is as flexible as just putting two relational predicates together with,. Maybe some logic-programming DSL for functional languages like minikaren found a good set of APIs for that, but I'm a little ignorant there.