I just want to point this out.
init=OnInit(f) is another one of these things like Union{T,Nothing} I'm always complaining about, which I might be calling "unbalanced unions". This instance is much milder than most because it's in the argument rather than the return and OnInit is pretty much only for this purpose.
reduce(op, xs; init=OnInit(f)) doesn't pass an OnInit value to op. Instead it special-cases init values of that type and calls the function inside it. It'll probably be fine, but this isn't really correct. More properly it should be reduce(op, xs; oninit=f) or rejigger the whole init API to require a wrapper reduce(op, xs, Init(0)) | reduce(op, xs, OnInit(f)).
I just want to point this out.
init=OnInit(f)is another one of these things likeUnion{T,Nothing}I'm always complaining about, which I might be calling "unbalanced unions". This instance is much milder than most because it's in the argument rather than the return andOnInitis pretty much only for this purpose.reduce(op, xs; init=OnInit(f))doesn't pass anOnInitvalue toop. Instead it special-casesinitvalues of that type and calls the function inside it. It'll probably be fine, but this isn't really correct. More properly it should bereduce(op, xs; oninit=f)or rejigger the wholeinitAPI to require a wrapperreduce(op, xs, Init(0)) | reduce(op, xs, OnInit(f)).