# How to include more modules in one package?

**URL:** <https://discourse.julialang.org/t/how-to-include-more-modules-in-one-package/18664>\
**Category:** General Usage\
**Created:** [December 14, 2018, 4:13pm UTC](https://discourse.julialang.org/t/how-to-include-more-modules-in-one-package/18664 "2018-12-14T16:13:27Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eugeleo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eugeleo/32/6440_2.png) [@Eugeleo](https://discourse.julialang.org/u/Eugeleo)\
**Post date:** [December 14, 2018, 4:13pm UTC](https://discourse.julialang.org/t/how-to-include-more-modules-in-one-package/18664/1 "2018-12-14T16:13:27Z")

</div>

I’m making my first package for Julia (text generator based on Markov chains) and I’d like it to export two modules: Markovify and Markovify.Tokenizer, so that both will be available to be `used` in the users code. How do I do this as a developer?

Currently I have simply two files with two modules, but only the module named Markovify (which is the same as the package name) seems to be exported.

Thank you.

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [December 14, 2018, 4:19pm UTC](https://discourse.julialang.org/t/how-to-include-more-modules-in-one-package/18664/2 "2018-12-14T16:19:58Z")

</div>

The user would not be able to input `using Markovify.Tokenizer` before `using Markovify` first. If you wish to be able to load the `Tokenizer` package without first invoking `Markovify`, then it needs to be a separate package, so that the package manager recognizes it separately.

---

<div class="post-metadata">

**Author:** ![Eugeleo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eugeleo/32/6440_2.png) [@Eugeleo](https://discourse.julialang.org/u/Eugeleo)\
**Post date:** [December 14, 2018, 5:16pm UTC](https://discourse.julialang.org/t/how-to-include-more-modules-in-one-package/18664/3 "2018-12-14T17:16:02Z")

</div>

That doesn’t concern me, Markovify.Tokenizer will be used only when using Markovify anyway. Just to be sure; to be able to make this, I should do something like:

file1.jl

```julia
module Markovify
[...]
end

```

file2.jl

```julia
module Markovify
    module Tokenizer
    [...]
    end
end

```

Right?

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [December 14, 2018, 5:45pm UTC](https://discourse.julialang.org/t/how-to-include-more-modules-in-one-package/18664/4 "2018-12-14T17:45:49Z")

</div>

Probably more like this, actually

Markovify.jl

```nohighlight
module Markovify
include("file2.jl")
[...]
end

```

file2.jl

```nohighlight
module Tokenizer
    [...]
end

```

---

<div class="post-metadata">

**Author:** ![Eugeleo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eugeleo/32/6440_2.png) [@Eugeleo](https://discourse.julialang.org/u/Eugeleo)\
**Post date:** [December 15, 2018, 7:54am UTC](https://discourse.julialang.org/t/how-to-include-more-modules-in-one-package/18664/5 "2018-12-15T07:54:05Z")

</div>

That was what I’ve been missing! Worked great, thanks. No clue why my version didn’t work, though; any pointers?

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [December 15, 2018, 9:21am UTC](https://discourse.julialang.org/t/how-to-include-more-modules-in-one-package/18664/6 "2018-12-15T09:21:44Z")

</div>

In your version you’ve defined two different modules with the same name, `Markovify`. One contained the `Tokenizer` module and one didn’t.

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [December 15, 2018, 11:48am UTC](https://discourse.julialang.org/t/how-to-include-more-modules-in-one-package/18664/7 "2018-12-15T11:48:00Z")

</div>

The package manager looks in the `src` directory for a file with the same name as the package, so `file1.jl` will not be found. You have to `include` the other files from the main module file to load them.
