I would like mapfoldr
to infer on a Tuple
. MWE:
using Test
prefix_combinations(x, y) = vec(((x, y) > (x, y...)).(x, permutedims(y)))
@inferred prefix_combinations([1, 2], [(3, ), (4, )]) # OK
f1(D) = mapfoldr(Base.OneTo, prefix_combinations, D; init = [()])
@inferred f1((2, 3)) # FAILS
I can of course just write a recursive version that works:
mapfoldr_recursive(acc, f, op) = acc
function mapfoldr_recursive(acc, f, op, first, rest...)
mapfoldr_recursive(op(f(first), acc), f, op, rest...)
end
f2(D) = mapfoldr_recursive([()], Base.OneTo, prefix_combinations, reverse(D)...)
@inferred f2((2, 3)) # OK
but I am wondering

if there is a way to do this with
mapfoldr
somehow out of the box, or in a simpler way, 
if not, whether contributing this to
Base
would make sense as a special case, or if there is a package that does this already.