# Having IJulia show "text/org" mimetype without type-piracy

**URL:** https://discourse.julialang.org/t/having-ijulia-show-text-org-mimetype-without-type-piracy/9993
**Category:** General Usage
**Tags:** question, jupyter
**Created:** [March 26, 2018, 1:41pm UTC](https://discourse.julialang.org/t/having-ijulia-show-text-org-mimetype-without-type-piracy/9993 "2018-03-26T13:41:44Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)
#### Post date: [March 26, 2018, 1:41pm UTC](https://discourse.julialang.org/t/having-ijulia-show-text-org-mimetype-without-type-piracy/9993/1 "2018-03-26T13:41:44Z")

</div>

I’ve been using [`ob-ipython`](https://github.com/gregsexton/ob-ipython) in  
org-mode lately with ijulia as the kernel. In general, it works pretty well and  
papers over some of the current issues with `ob-julia`. The one thing it doesn’t  
do natively is formatting the results as org-mode tables when an array or  
dataframe is returned. To get around this, I currently have the following  
snippet in my `.juliarc.jl` (definition for `orgify` not shown but can be shared  
if interest).

```julia
"Tries to represent arrays as an org-table"
function Base.show(st::IO, ty::MIME"text/org", x::AbstractArray)
    stringrepresentations = map(string,x)
    write(st, orgify(stringrepresentations))
end

"Tries to represent as an org-table"
function Base.show(st::IO, ty::MIME"text/org", x)
    write(st, orgify(x))
end

```

This works fairly well for my purposes, but it occurred to me that this is  
functionality probably worth sharing (whether shared as julia package or emacs  
package yet to be determined). However, I shouldn’t really be publishing a package  
anywhere that has this kind of type-piracy. Any ideas how to avoid the  
type-piracy here?

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [March 26, 2018, 2:12pm UTC](https://discourse.julialang.org/t/having-ijulia-show-text-org-mimetype-without-type-piracy/9993/2 "2018-03-26T14:12:21Z")

</div>

Make a PR to `Base`.

---

<div class="post-metadata">

### Author: ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)
#### Post date: [March 26, 2018, 2:57pm UTC](https://discourse.julialang.org/t/having-ijulia-show-text-org-mimetype-without-type-piracy/9993/3 "2018-03-26T14:57:25Z")

</div>

It doesn’t seem like something that special-purpose really belongs in Base.  
Could make sense to PR into DataFrames though for that part of things.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [March 26, 2018, 3:02pm UTC](https://discourse.julialang.org/t/having-ijulia-show-text-org-mimetype-without-type-piracy/9993/4 "2018-03-26T15:02:40Z")

</div>

Sorry, I was confused and thought that `MIME"text/org"` types are used in `Base`. If they are not, I don’t think type piracy is an issue (recall that `MIME` is a parametric type). I would just put it wherever `orgify` is.

---

<div class="post-metadata">

### Author: ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)
#### Post date: [March 26, 2018, 3:07pm UTC](https://discourse.julialang.org/t/having-ijulia-show-text-org-mimetype-without-type-piracy/9993/5 "2018-03-26T15:07:54Z")

</div>

Issue is that `AbstractArray` is defined in Base even if you’re right about the  
thing where parametric types don’t count as type-piracy so long as the specific  
parameter isn’t used in the original package. Or maybe I’m just totally  
misunderstanding what is meant by “type-piracy”.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [March 26, 2018, 3:13pm UTC](https://discourse.julialang.org/t/having-ijulia-show-text-org-mimetype-without-type-piracy/9993/6 "2018-03-26T15:13:45Z")

</div>

I would make [this suggestion](https://discourse.julialang.org/t/even-more-clarification-on-type-piracy/9079/2) again — if there is at least one type in the signature that you “own”, defining a method it is not type piracy.

I understand the concern about `MIME` — “ownership” can be hazy with parametric types — but I think that the idea behind it is precisely that people should extend it.

---

<div class="post-metadata">

### Author: ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)
#### Post date: [March 26, 2018, 5:37pm UTC](https://discourse.julialang.org/t/having-ijulia-show-text-org-mimetype-without-type-piracy/9993/7 "2018-03-26T17:37:05Z")

</div>

The inverse, i.e. reading org tables is here: [https://github.com/mauro3/OrgTables.jl](https://github.com/mauro3/OrgTables.jl). Feel free to use to consolidate all the functionality.
