# Properly exporting foreign types in module - for save/load JLD2

**URL:** https://discourse.julialang.org/t/properly-exporting-foreign-types-in-module-for-save-load-jld2/15822
**Category:** General Usage
**Tags:** question
**Created:** [October 3, 2018, 9:30am UTC](https://discourse.julialang.org/t/properly-exporting-foreign-types-in-module-for-save-load-jld2/15822 "2018-10-03T09:30:03Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![JonasIsensee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jonasisensee/32/4704_2.png) [@JonasIsensee](https://discourse.julialang.org/u/JonasIsensee)
#### Post date: [October 3, 2018, 9:30am UTC](https://discourse.julialang.org/t/properly-exporting-foreign-types-in-module-for-save-load-jld2/15822/1 "2018-10-03T09:30:03Z")

</div>

Hey!  
I’ve got a questing on modules and (re-)exporting types imported from another module.  
The MWE below shows my problem.  
I want to use/export a type from a different module. This works fine.  
However I cannot load such an object from file.

Two workarounds are to either do `import Distances` manually or to use `@reexport` in my module.  
The first option is not really satisfactory and the second one clutters my namespace  
since I only need one single name out of a large package.  
(`Distances` was only an example )

```julia
julia> module Foo
           import Distances:Euclidean
           export Euclidean
       end
Main.Foo

julia> bar = Foo.Euclidean()
Distances.Euclidean(0.0)

julia> using FileIO

julia> save("testfile.jld2", "bar", bar)

julia> bar2 = load("testfile.jld2", "bar")
┌ Warning: type Distances.Euclidean does not exist in workspace; reconstructing
└ @ JLD2 ~/.julia/packages/JLD2/KjBIK/src/data.jl:1153
getfield(JLD2.ReconstructedTypes, Symbol("##Distances.Euclidean#358"))(0.0)

julia> bar == bar2
false

ulia> import Distances

julia> bar3 = load("testfile.jld2", "bar")
Distances.Euclidean(0.0)

julia> bar == bar3
true

```
