DataspacePatterns: patterns over sets of literals #5

Open
opened 2023-06-08 10:17:28 +00:00 by ehmry · 2 comments
Contributor

Set of patterns are awkward but sets of literals make sense as a constrained array pattern.

Set of patterns are awkward but sets of literals make sense as a constrained array pattern.
Owner

Yes, though I'm cautious about introducing alternation within a pattern. Mostly because of the implemention of dataspaces.

Consider a pattern like

<arr [<litset #{1 2 3}> <litset #{4 5 6}> <litset #{7 8 9}>]>

The way the "skeleton" structure used in the Racket/Rust/TypeScript dataspace implementations works is:

  1. filter assertions by overall shape (the "skeleton") of constructors.
  2. filter assertions by projecting out positions in the assertion expected to be constant, and comparing the values found there to expected values in observers.

At step 2, we would have to have a cartesian product of all possible combinations for the three slots in the pattern array (1 4 7, 1 4 8, 1 4 9, ... , 2 6 7, ... , 3 6 9). We currently use a simple array because we know there can only be one possible expected-value at each position in the projection. To accommodate a cartesian product, we would have to switch to something more complex like a(nother) trie or something.

Yes, though I'm cautious about introducing alternation *within* a pattern. Mostly because of the implemention of dataspaces. Consider a pattern like <arr [<litset #{1 2 3}> <litset #{4 5 6}> <litset #{7 8 9}>]> The way the "skeleton" structure used in the Racket/Rust/TypeScript dataspace implementations works is: 1. filter assertions by overall shape (the "skeleton") of constructors. 2. filter assertions by projecting out positions in the assertion expected to be constant, and comparing the values found there to expected values in observers. At step 2, we would have to have a cartesian product of all possible combinations for the three slots in the pattern array (1 4 7, 1 4 8, 1 4 9, ... , 2 6 7, ... , 3 6 9). We currently use a simple array because we know there can only be one possible expected-value at each position in the projection. To accommodate a cartesian product, we would have to switch to something more complex like a(nother) trie or something.
Owner

Another approach is to imagine sets as being something like Dictionaries mapping their values to some constant, say #t. Then we can reuse the matching we permit over Dictionaries: we treat set members / dictionary keys as steps in a structural path, only leading to "no values" with sets rather than the target value with dictionaries.

Another approach is to imagine sets as being something like Dictionaries mapping their values to some constant, say `#t`. Then we can reuse the matching we permit over Dictionaries: we treat set members / dictionary keys as steps in a structural path, only leading to "no values" with sets rather than the target value with dictionaries.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: syndicate-lang/syndicate-protocols#5
No description provided.