generic-data-surgery icon indicating copy to clipboard operation
generic-data-surgery copied to clipboard

Add support for strict fields surgery

Open blmage opened this issue 6 years ago • 2 comments

First of all, thanks for the awesome library again!

I've started working on adding support for strict fields, using a variant of DefaultMetaSel to begin with.

As it turned out after some tests, it would probably be much better to account for every possible combination of SourceUnpackedness, SourceStrictness and DecidedStrictness, and that does not seem to cope well with using variants of DefaultMetaSel.

I guess that one way to do it would be to make it so that strictness annotations are disregarded / unified when moving in and out of the OR, but do you know if that would be at all feasible? If so, would you have any pointer as to how to do it?

Finally, perhaps most importantly, would you be interested with this feature being added to your library?

Thanks!

blmage avatar Apr 25 '20 14:04 blmage

Sure, that sounds like a good feature to have!

As you suggest, we could scrub out the strictness annotations (and possibly other metadata) at the edges of the OR, if they don't matter. That could be done by separate versions of toOR and fromOR, where instead of (FromOR (Rep a) l) the constraint would be something like (FromOR (ClearFields (Rep a)) l). (Separate versions because I think it's better if the default toOR and fromOR don't do this as it might change semantics for those who care.)

A more fine-grained feature (but it would make sense to have both this and that) is to generalize InsertField to take the whole MetaSel as an argument instead of just the fd field descriptor.

Lysxia avatar Apr 25 '20 16:04 Lysxia

Thanks for the prompt feedback and the helpful pointers!

I took a stab at implementing the first solution in #8 (which perfectly fits my use case!), and I might come back at trying to implement the second solution later.

blmage avatar Apr 26 '20 10:04 blmage