JuliaLang / Compat.jl

Compatibility across Julia versions
Other
145 stars 117 forks source link

Backport ComposedFunction #720

Closed tkf closed 3 years ago

tkf commented 4 years ago

I suggest adding Compat.ComposedFunction when/if https://github.com/JuliaLang/julia/pull/37517 is merged. This way, individual packages like DataFrames.jl don't have to implement the same hack.

martinholters commented 4 years ago

Would we want to add the constructors, too? It's a bit tricky, but something along these lines would work:

@eval ComposedFunction{F,G}(f,g) where {F,G} = $(Expr(:new, :(ComposedFunction{F,G}), :f, :g))
parentmodule(typeof(h)).eval(:($(nameof(typeof(h)))(f::F, g::G) where {F,G} = $(nameof(typeof(h))){F,G}(f,g)))