DisplayAs.jl icon indicating copy to clipboard operation
DisplayAs.jl copied to clipboard

Deprecate `Showable{T}(::Showable{S})`

Open tkf opened this issue 4 years ago • 0 comments

Using Showable{T}(::Showable{S}) for extending allowed MIME has an unfortunate consequence that the basic invariance T(...)::T for constructors does not hold. However, since x |> DisplayAs.HTML |> DisplayAs.Text is a very handy way of specifying allowed MIMEs, it'd be nice to have an API as concise as this before deprecating Showable{T}(::Showable{S}). A few ideas on the API:

(1) displayas(x, mimes_or_file_extensions...) to specify a list of allowed MIMEs. For example, the example above may be written as displayas(x, :html, :text) and displayas(x, "text/html", MIME"text/plain"()) etc.

(2) Switch to factory functions DisplayAs.html, DisplayAs.text, etc. so that they don't have to be types.

@fredrikekre Any thoughts?

tkf avatar Mar 15 '22 03:03 tkf