I have my own type “cyclotomics” (sums of roots of unity) for which I have a fancy display which I want to see at the REPL. I want also to have a function which can output my numbers in a way which can be read back in (I assume this function should be repr
but perhaps there is a better choice).
In other terms, I want to see at the REPL:
julia> l
4×4 Array{Cyc{Int64},2}:
2 0 -ζ₃² 1+ζ₄
0 -2 2ζ₃+ζ₃² -1+ζ₄
-ζ₃² 2ζ₃+ζ₃² 2ζ₃ ζ₁₂⁴-ζ₁₂⁷-ζ₁₂¹¹
1+ζ₄ -1+ζ₄ ζ₁₂⁴-ζ₁₂⁷-ζ₁₂¹¹ 2ζ₄
while
julia> repr(l)
"Cyc{Int64}[2 0 -E(3,2) 1+E(4); 0 -2 2E(3)+E(3,2) -1+E(4); -E(3,2) 2E(3)+E(3,2) 2E(3) E(12,4)-E(12,7)-E(12,11); 1+E(4) -1+E(4) E(12,4)-E(12,7)-E(12,11) 2E(4)]"
To be able to achieve this, I need to detect within show
that I am somewhere deep below a call starting from the REPL. Is there a way? Or is my design wrong and there is another way to accomplish the same aim?