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

predicate function negation with ComposedFunction #44752

Merged
merged 7 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tweak show() for ComposedFunction
  • Loading branch information
markmbaum authored and vtjnash committed Apr 7, 2022
commit 49c46dde8e8e2ef1450fa514a840601f51d14a5d
18 changes: 16 additions & 2 deletions base/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ end
∘(f, g, h...) = ∘(f ∘ g, h...)

function show(io::IO, c::ComposedFunction)
_showcomposed(io, c.outer)
c.outer isa ComposedFunction ? show(io, c.outer) : _showcomposed(io, c.outer)
print(io, " ∘ ")
_showcomposed(io, c.inner)
end
Expand All @@ -1052,7 +1052,21 @@ _showcomposed(io::IO, f::Function) = isoperator(Symbol(f)) ? (print(io, '('); sh
#nesting for chained composition
_showcomposed(io::IO, f::ComposedFunction) = (print(io, '('); show(io, f); print(io, ')'))
#no nesting when ! is the outer function in a composition chain
_showcomposed(io::IO, f::ComposedFunction{typeof(!)}) = (print(io, '!'); show(io, f.inner))
_showcomposed(io::IO, f::ComposedFunction{typeof(!)}) = show(io, f)

function show_function(io::IO, c::ComposedFunction, compact::Bool)
if compact
show(io, c)
else
print(io, "ComposedFunction(")
show_function(io, c.outer, false)
print(io, ", ")
show_function(io, c.inner, false)
print(io, ')')
end
end

show_function(io::IO, x, ::Bool) = show(io, x)
markmbaum marked this conversation as resolved.
Show resolved Hide resolved

"""
!f::Function
Expand Down
14 changes: 0 additions & 14 deletions base/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -468,20 +468,6 @@ end
show(io::IO, f::Function) = show_function(io, f, get(io, :compact, false)::Bool)
print(io::IO, f::Function) = show_function(io, f, true)

function show_function(io::IO, c::ComposedFunction, compact::Bool)
if compact
show(io, c)
else
print(io, "ComposedFunction(")
show_function(io, c.outer, false)
print(io, ", ")
show_function(io, c.inner, false)
print(io, ')')
end
end

show_function(io::IO, x, ::Bool) = show(io, x)

function show(io::IO, f::Core.IntrinsicFunction)
if !(get(io, :compact, false)::Bool)
print(io, "Core.Intrinsics.")
Expand Down