Open SBuercklin opened 1 year ago
I can take a shot at this in a day or two, but a potential resolution, at least for the checker, looks like it would be to sort the pairs
by depth of the types in the tree. This way, we start with higher (more abstract) types and proceed down the tree to the concrete/leaf types.
Then we can resolve contradictory traits by either the latest trait assigned to the type itself, or the last supertype which had the trait assigned to it
Relevant lines: https://github.com/tk3369/BinaryTraits.jl/blob/master/src/assignment.jl#L12-L16
@SBuercklin I think this package is dead. No commits > 3 years and no response here in a year. It is breaking on julia 1.10. We are going to move away from it. What are you using these days?
I opened an issue for the break on 1.10 on this repo, it's related to a bug in 1.10.0 and there's a stopgap fix in that issue
As for replacements I've continued to use this. If I were to try something different it would likely be RequiredInterfaces.jl, but I've not tested it out yet.
Currently, I don't have the bandwidth to do any substantial work in this repo. Happy to review contribution or answer any question, however. There are other trait packages around so you could also check them out. I am not familiar with the maturity and potential tradeoffs, however.
I would like to apply a default trait to an abstract type, and then special case some subtypes with the negated trait. Take for example below:
Foo
passes the check, butgetfoo(Foo())
fails because I haven't implementedgetfoo(::Foo)
yet in accordance with theIs{A_Foo}
interface. This behavior seems nuanced since it requires associating only one ofIs{A_Foo}
orNot{A_Foo}
to each type at a time, so it may contradictBinaryTraits
's implementation.Alternatively, if there's a better way/a design pattern to achieve this behavior (default trait applied to abstract type, special cased implementation of the negated trait to subtypes) I am open implementing that instead