Implement applyl_at and applyr_at functions#208
Draft
redbaron wants to merge 2 commits intolloydmeta:masterfrom
Draft
Implement applyl_at and applyr_at functions#208redbaron wants to merge 2 commits intolloydmeta:masterfrom
redbaron wants to merge 2 commits intolloydmeta:masterfrom
Conversation
Author
|
Added |
lloydmeta
reviewed
Mar 4, 2023
Owner
lloydmeta
left a comment
There was a problem hiding this comment.
Out of curiosity, what is the use case for this?
In general, I'd like to avoid failable-at-runtime things in this crate because it feels like we could avoid them since we (should) know almost everything at compile time. For instance, we could use a Labelled Hlist, pluck out the element we want by type (we'd get a compile time error if it does not exist or is duplicated), then apply a function?
Author
|
Not everyting is known at compile time. In my experiments I have a "query plan" (list of operations) in the HList and need to execute them in order when right conditions arise, hence the runtime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
It adds
applyl_atandapplyr_atfunctions which apply single argument function to thenth HList element. It is implemented as a fold function which carries target and current depth levels as well as function application result in the accumulator.Because
ncan be outside of the hlist length, function returnsOption<_>withNonereturned ifnis larger than list size.It also has
apply*_args_atvariants which addsargsparam to the accumulator to be passed to the function as a poor replacement for missingself(and therefore closure) param.This is a draft PR to collect early feedback, more specifically:
HCons?