Skip to content
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

Better set operations #2

Open
cvogt opened this issue Feb 10, 2015 · 5 comments
Open

Better set operations #2

cvogt opened this issue Feb 10, 2015 · 5 comments

Comments

@cvogt
Copy link
Owner

cvogt commented Feb 10, 2015

currently there is & which is a union operator on the key value pairs. The default should probably rather be a disjoint union that throws a type error in case of overlap.

Overview of useful operators that should be implemented

  • Union, rhs fields replace lhs fields (currently implemented as &)
  • Disjoint Union, e.g. |
  • Intersection, e.g. &
  • Minus, e.g. r \ (select field1 & field2) or r(remove field1 & field2) or
  • Recursive Union, struct fields merge, non-struct fields replace
@vjovanov
Copy link

Overlap is sometimes perfectly valid. Requiring users to rename their records could be a too big burden. Maybe you can introduce a default scheme for resolving conflicts.

@cvogt
Copy link
Owner Author

cvogt commented Feb 11, 2015

@vjovanov I am thinking to have one operator that simple overrides and one that fails on conflicts. I don't think I like automatic conflict resolution that alters the structure. Maybe if it is demanded at some point. For now I am just planning to add a way to actually RENAME fields: #5

@vjovanov
Copy link

That is a good strategy, if users need it you can always build on top of it. In scala-records we will use the structural types for this.

@cvogt
Copy link
Owner Author

cvogt commented Feb 11, 2015

@vjovanov for what exactly? Renames? How would the syntax be?

@vjovanov
Copy link

Yep for renames, although they would be rather nested records. If you merge two records the collided fields would be in the nested record:

Rec { 
  lhs: Rec { collidedField: String }
  rhs: Red { collidedField: String }
  // .. the rest
} 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants