frunk
frunk copied to clipboard
Implement applyl_at and applyr_at functions
It adds applyl_at and applyr_at functions which apply single argument function to the nth 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 n can be outside of the hlist length, function returns Option<_> with None returned if n is larger than list size.
It also hasapply*_args_at variants which adds args param to the accumulator to be passed to the function as a poor replacement for missing self (and therefore closure) param.
This is a draft PR to collect early feedback, more specifically:
- is it something you'd like to see in this crate?
- should it be standalone function like it is now or you prefer it to be a method on the
HCons? - functions/arguments naming suggestions.
Added apply*_args_at variants
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 n param to pick one to run.