-
Notifications
You must be signed in to change notification settings - Fork 69
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
docs(patterns): Comments for fixed-length heterogeneous collection patterns #2291
Conversation
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.
Looks good so far. Do this symmetrically for CopyArrays, Taggeds, CopyMaps, and passable primitives. I think that covers all the cases, but you should double check whether I forgot anything.
420ba6e
to
58dec29
Compare
7ff741e
to
72e6090
Compare
@@ -1651,13 +1651,26 @@ const makePatternKit = () => { | |||
limits ? makeLimitsMatcher('match:symbol', [limits]) : SymbolShape, | |||
record: (limits = undefined) => | |||
limits ? M.recordOf(M.any(), M.any(), limits) : RecordShape, | |||
// The pattern for a CopyRecord with a fixed quantity of heterogeneous | |||
// entry types (a Struct) is merely a hardened object with the respective |
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.
x
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.
Shouldn't this be
// entry types (a Struct) is merely a hardened object with the respective | |
// value types (a Struct) is merely a hardened object with the respective |
Also, I'm uncomfortable making the connection to types in a way that sound stronger than just a metaphor. TS types are both more and less expressive than patterns. Neither is a subset of the other.
// entry types (a Struct) is merely a hardened object with the respective | |
// value patterns (a Struct) is merely a hardened object with the respective |
That "hardened object" is itself a CopyRecord btw. Put more simply, a CopyRecord whose property values are patterns is itself a pattern. I don't know if this helps.
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 rewrote all sections to convey this clarification.
// The pattern for a CopyMap with a fixed quantity of heterogeneous entry | ||
// types is merely a CopyMap of corresponding key and value patterns, for | ||
// example, | ||
// makeCopyMap([[M.string(), M.number()], [M.number(), M.string()]]). |
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.
No. The keys must be keys. Only the values can be non-key patterns.
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.
Rewrote record and map to clarify this distinction.
72e6090
to
1f51d83
Compare
6ce1307
to
705a32c
Compare
Rewrote all sections to speak in terms of the copy data that each pattern matches instead of using TypeScript. Covered CopyRecord, CopyArray, and CopyMaps. Tags aren’t heterogeneous collections. CopySet and CopyBag are collections but can’t be fixed-length and heterogeneous with types for corresponding keys or indexes, so they’re out. |
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.
LGTM, thanks!
705a32c
to
a39d236
Compare
Until we have a rigorous treatment on the usage of patterns, this adds a bandaid to the code itself so anyone looking for how to make a pattern for a struct-like CopyRecord, tuple-like CopyArray, or fixed-length heterogeneous CopyMap will find their way.