Local modules

How to work with multiple local linked modules? I have read through the similar topics in discourse but didn’t find a suitable solution.

I have one main module which uses 2 modules: ModA and helper.
Module modA also uses module helper.

Main.jl

include("helper.jl")
using .helper

include("ModA.jl")

mean_vector = [0, 1]
Aexp = expansion(mean_vector)
ModA.solve(Aexp)

ModA.jl

module ModA
export solve

include("helper.jl")
using .helper

function solve(A::expansion)
    println(A.mean)
end

end

helper.jl

module helper
export expansion

struct expansion
    mean::Vector{Float64}
end

end

When calling Main.jl I get the following error:
MethodError: no method matching solve(::expansion)
Closest candidates are:
solve(::Main.ModA.helper.expansion)

How can I solve the error?

The following works:

module ModA
export solve

using ..helper

function solve(A::expansion)
    println(A.mean)
end

end

Docs: Modules · The Julia Language

3 Likes