Alright, so I went ahead and implemented the requested feature, which works on master branch
julia> Reduce.@subtype FakeReal <: Real
julia> FakeReal(R"x+1") + FakeReal(R"y")
y + 1 + x
the implementation looks like this at the moment
macro subtype(x)
x.head ≠ :<: && throw(error("$x is not a subtype expression"))
name = x.args[1]
Expr(:struct,false,x,Expr(:block,Expr(:(::), :r, :RExpr))) |> eval
@eval begin
export $name
show(io::IO, r::$name) = show(io,r.r)
extract(r::$name) = r.r
Algebra.init_subtype($name)
end
nothing
end
and
function init_subtype(name)
Expr(:block,[:(Base.$i(r::$name...)=$i(extract.(r)...)|>$name) for i ∈ [alg;iops]]...) |> eval
Expr(:block,[:($i(r::$name...)=$i(extract.(r)...)|>$name) for i ∈ [calculus;cnan;cmat]]...) |> eval
Expr(:block,[:(Base.$i(r::$name)=$i(extract(r))|>$name) for i ∈ [sbas;[:length]]]...) |> eval
Expr(:block,[:($i(r::$name)=$i(extract(r))|>$name) for i ∈ [sfun;snan;snum;scom;sint;sran;smat]]...) |> eval
end
this provides all of the basic functions from the Reduce.Algebra module, but outside that, the new subtypes generated do not have the same treatment ast RExpr at the moment