cvogt / compossible

Scala Records: Extensible records and type-indexed maps
https://www.youtube.com/watch?v=pA2js-TV1Ck
82 stars 10 forks source link

Better set operations #2

Open cvogt opened 9 years ago

cvogt commented 9 years ago

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

vjovanov commented 9 years ago

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 commented 9 years ago

@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: https://github.com/cvogt/records/issues/5

vjovanov commented 9 years ago

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 commented 9 years ago

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

vjovanov commented 9 years ago

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
}