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

overloading Base.promote_type is not permitted #5

Open
nsajko opened this issue Apr 18, 2024 · 3 comments
Open

overloading Base.promote_type is not permitted #5

nsajko opened this issue Apr 18, 2024 · 3 comments

Comments

@nsajko
Copy link

nsajko commented Apr 18, 2024

Several methods are added for promote_type in this package. Xref JuliaLang/julia#54138

@schlichtanders
Copy link
Collaborator

Can you help how to replace it? This mirrors the typejoin and other behaviour of Nothing and Missing, how to do without promote_type? (I remember that Nothing and missing used this, but I may be wrong)

@nsajko
Copy link
Author

nsajko commented Apr 19, 2024

Would simply overloading promote_rule instead of promote_type work?

I'm not otherwise familiar with this package, but I took a look at the implementation now, and it seems to me that it's deeply flawed. For example, this:

const Either{L, R} = Union{Const{L}, Identity{R}}

... should instead look something like:

struct Either{L, R}
  v::R
end

So, it seems to me that you're misusing Union when you should be defining a new, named, type.

@schlichtanders
Copy link
Collaborator

Please, I ask you to be more respectful towards code you may not understand.
The types are carefully chosen and have advantages over defining structs.

As already said, the types Const and Identity behave similar to Nothing and Missing in that Union types get explicitly constructed. If you can tell me how to change the implementation without using promote_type, while not changing the type definitions, I am very happy to change it.

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

2 participants