Skip to content

Commit

Permalink
Tweak printing of Julia parent types (#1883)
Browse files Browse the repository at this point in the history
So that e.g. `Integers{BigInt}` and `Integers{Int}` don't print
identically.
  • Loading branch information
fingolfin authored Nov 8, 2024
1 parent f90e000 commit 174cdc9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/julia/Float.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,14 @@ is_positive(n::T) where T<:Real = n > zero(T)
#
###############################################################################

function show(io::IO, R::Floats)
function show(io::IO, R::Floats{BigFloat})
print(io, "Floats")
end

function show(io::IO, R::Floats{T}) where T
print(io, "Floats{$T}()")
end

function expressify(a::AbstractFloat; context = nothing)
if a < 0
return Expr(:call, :-, string(-a))
Expand Down
6 changes: 5 additions & 1 deletion src/julia/Integer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,14 @@ function expressify(a::Integer; context = nothing)
return a
end

function show(io::IO, R::Integers)
function show(io::IO, R::Integers{BigInt})
print(io, "Integers")
end

function show(io::IO, R::Integers{T}) where T
print(io, "Integers{$T}()")
end

###############################################################################
#
# Modular arithmetic
Expand Down
6 changes: 5 additions & 1 deletion src/julia/Rational.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,14 @@ function expressify(a::Rational; context = nothing)
end
end

function show(io::IO, R::Rationals)
function show(io::IO, R::Rationals{BigInt})
print(io, "Rationals")
end

function show(io::IO, R::Rationals{T}) where T
print(io, "Rationals{$T}()")
end

###############################################################################
#
# Divides
Expand Down

0 comments on commit 174cdc9

Please sign in to comment.