-
Notifications
You must be signed in to change notification settings - Fork 1
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
chore: sketch of the power-line concept #3
Conversation
Signed-off-by: Irakli Gozalishvili <contact@gozala.io>
Signed-off-by: Irakli Gozalishvili <contact@gozala.io>
Signed-off-by: Irakli Gozalishvili <contact@gozala.io>
Signed-off-by: Irakli Gozalishvili <contact@gozala.io>
Signed-off-by: Irakli Gozalishvili <contact@gozala.io>
Signed-off-by: Irakli Gozalishvili <contact@gozala.io>
notes/conds.md
Outdated
### concrete proposal for the inital release | ||
|
||
Here's a sketch that shows the features | ||
|
||
```js | ||
{ | ||
"iss": "did:key:alice", | ||
// ... | ||
"policy": [ | ||
["var", ["?x", "?y"], // The `?` here is just by convention | ||
["args", "foo..bar.[].baz", "?x"], | ||
[["some", "match"], "?x", "*@example.com"], | ||
|
||
["args", "foo.quux", "?y"], | ||
[">", "?y", 42], | ||
["<", "?x", "?y"] | ||
] | ||
] | ||
} | ||
``` | ||
|
||
Of note: | ||
|
||
* Selector syntax based on JSONPath / JSON Poiniter / jQ | ||
* `"foo..bar.[].baz"` ~ `foo.{*recursive descent*}.bar.{ALL}.baz` | ||
* `var` is like `fresh` in minikanren: introduces logic variables | ||
* these give the ability to run predicate logic in the middle of a sector | ||
* `[[<node>, <path>, "?x"], [<pred>, "?x", <expr>]` | ||
* Declarative matching from `args` onwards | ||
* Anything of the form `[<node>, <selector>, <value or variable>]` | ||
* Can avoid namespace conflicts because users define variable names locally | ||
* Recurses if needed | ||
* A trivial case: `[["args", "some.path", "?x"], ["?x", "more.path", 42]]` | ||
* Matches `args.some.path.more.path == 42` | ||
* Use of `args` to start the path allows us to open up the synatx over time if we want | ||
* Plus it's very declarative |
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.
cc @Gozala thoughts?
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.
Perhaps worth noting that the above also lets us avoid ==
in a lot of common cases, too:
["args", "some.path", 42]
is like {==: {args: {some: {path: 42}}}}
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.
Odd thing about ["args", "some.path", "?x"]
is that it's bit unclear if e.g. this would be valid
["", "args.some.path", "?x"]
or this ["args.some", "path", "?x"]
I feel like it may make more sense to think of args
as a built-in pre-poulated variable. perhaps ?
could be that. Or maybe for built-in variables we could use different prefix so we could introduce new ones in the future without colliding with user defined variables.
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.
["", "args.some.path", "?x"]
I think that we can't run the selector on ""
, so it should fail, right?
perhaps ? could be that
Yeah, exatcly: I was thinking of args
as that pre-populated variable. How about ?args
for consistent variable syntax?
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.
so we could introduce new ones in the future without colliding with user defined variables.
Not a bad idea, though I think it's up to the user to avoid collisions. We have a schema type in the capsule, so we know what's reserved.
We could introduce more syntax like $env
($args
), which feels maybe appropriate? It's is from the $environment
Co-authored-by: Irakli Gozalishvili <contact@gozala.io> Signed-off-by: Brooklyn Zelenka <be.zelenka@gmail.com>
Co-authored-by: Irakli Gozalishvili <contact@gozala.io> Signed-off-by: Brooklyn Zelenka <be.zelenka@gmail.com>
Co-authored-by: Vasco Santos <santos.vasco10@gmail.com> Signed-off-by: Irakli Gozalishvili <contact@gozala.io>
Breaking out some of the discussion points into separate issues
some
#7every
expression #8