Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OnInit/CopyInit require dispatching on unbalanced union #32

Open
jariji opened this issue Mar 2, 2024 · 0 comments
Open

OnInit/CopyInit require dispatching on unbalanced union #32

jariji opened this issue Mar 2, 2024 · 0 comments

Comments

@jariji
Copy link

jariji commented Mar 2, 2024

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)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant