You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Predicate function negation (source code) (proposed in #44748 and implemented in #44752) defines a method to simplify the case of !!f to f. Based on this, I propose implementing three similar simplifications.
This doesn't seem algebraically complete unless we have (identity ∘ !) === (!) (or for identity plus any function) and (!) ∘ (!) === identity. In fact the existing method !(f::ComposedFunction{typeof(!)}) = f.inner is suspicious; I don't know why it isn't a method of ∘, so we need to work that out first.
Attempting to follow your suggestion, this is an improvement over my original proposal (after removing the simplifying method).
Base.:∘(::typeof(identity), f) = f
Base.:∘(::typeof(!), ::typeof(identity)) =!
Base.:∘(::typeof(!), ::typeof(!)) = identity
# this method is because you can still construct a `ComposedFunction(identity, f)`
Base.:∘(::typeof(!), f::ComposedFunction{typeof(identity)}) =!f.inner
Base.:∘(::typeof(!), f::ComposedFunction{typeof(!)}) = f.inner
I would also support only removing the simplifying method.
Ah, come to think of it the problem with !(!) === identity is that ! is more restricted in what arguments it accepts than identity, so it's not really an equivalence.
Predicate function negation (source code) (proposed in #44748 and implemented in #44752) defines a method to simplify the case of
!!f
tof
. Based on this, I propose implementing three similar simplifications.Current
Proposed
As demonstrated, these methods can simplify several cases while preserving semantics. If this seems like a good idea, I'd be happy to make a PR.
The text was updated successfully, but these errors were encountered: