This repository was archived by the owner on Jan 10, 2023. It is now read-only.
Proof-of-concept implementation of Static Structural #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Based on explorations of structural generic programming in
tensorflow/swift-models#650 we would like to support
smooth interactions between KeyPaths and structural generic programming.
Based on discussions with @shabalind, I have put together a quick
proof-of-concept demonstrating how to unify a "static structural"
implementation with the "instance"-level structural generic programming we
have been exploring so far.
This is definitely an incomplete implementation, but this would allow us to
easily implement KeyPathIterable and its ilk on top of structural generic
programming (something not possible previously), in addition to unifying with
the existing KeyPath world.
There are a couple further extensions:
HNil
To use a proper cons-list construction, this willrequire a bottom type (
Never
) that conforms to every protocol, andmultiple conformances. Alternatively, an encoding that appears to work
is a cons-list construction that doesn't use a special end type.
these kinds of derived conformances.
although this is straight forward to add.
derived conformance, we can easily implement multiple simpler "structural"
encodings (e.g. a simple Cons-list of values in addition to the current
structural representation).
paths themselves. (i.e. if you could retrieve the field name corresponding
to the key path.)