jw3126 / Setfield.jl

Update deeply nested immutable structs.
Other
167 stars 17 forks source link

Possibility of loosening type-strict equality of indices #165

Closed phipsgabler closed 2 years ago

phipsgabler commented 2 years ago

The problem I have is this:

julia> @lens(_[1:10]) == @lens(_[Base.OneTo(10)])
false

julia> @lens(_[1:10]).indices == @lens(_[Base.OneTo(10)]).indices
true

arising from the dispatch on a common type in the definition:

==(l1::IndexLens{I}, l2::IndexLens{I}) where {I} = l1.indices == l2.indices

I'm asking if there's a possibility of loosening this to

==(l1::IndexLens, l2::IndexLens) = l1.indices == l2.indices

(and the same for ComposedLens). I think this is sensible, since if index values are considered equal, they (hopefully) should also index to equal things.

(I am to blame for this my self anyway :P)

jw3126 commented 2 years ago

Yes this sounds reasonable.