-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add openStructOption & structOption #5
base: main
Are you sure you want to change the base?
Conversation
fix the error output of /*
(struct {name = string;}) { addr = "xxx"; }
=>
expected 'anon'-struct, but found:
missing required string field 'name'
unexpected struct field 'addr
(struct {age = string;}) { addr = "xxx"; }
=>
expected 'anon'-struct, but found:
missing required int field 'age'
unexpected struct field 'addr'
either (struct {name = string;}) (struct { age = int; }) { addr = "xxx"; }
=>
expected type 'either<anon, anon>', but value '{
addr = "xxx";
}' is of type 'set'
after
|
4568cbb
to
cde27c2
Compare
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.
Would an option struct not better pe composed of a strict with option
type?
err = ""; | ||
}; | ||
# Function to check if a field should be ignored | ||
shouldIgnore = n: ignored || hasAttr n def; |
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 fail to grok how hasAttr n def
translates to the concept of "should ignore". Could you find a more suitable name?
in | ||
if shouldIgnore n | ||
then | ||
if hasAttr n def |
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.
This is somewhat redundant, because it's already checked in one branch of shouldIgnore
.
Maybe it's just the naming that confuses me here 😊
Ideally, the redundant branches could be unified.
Edit: for clarity I suggest you do a plain 3-branch case (if else) statement (ignored/hasattr/else)
=> | ||
{ Inputs = { ... }; } | ||
*/ | ||
structOption = arg: |
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 parse this name as an "option for a struct", but it rather is a "struct with all elements being optional".
The field type must be included within the {...} structAttrs.
If the field type exists within {...} structAttrs
contrast with: