Using everything exported in a module and its submodules

K5Julien
Sun, 14 Jul 2024 08:09:07 +0000
New to Julia

I am currently replacing some String arguments of my mutable structure with dedicated types instead.

The following MWE works perfectly fine:

module MyPackage
  ### Some code
  module Options

      module SolveMod
          struct Both end  # public interface
          struct BranchBendersCut end  # public interface
          ## Some other options...
          const USolveMod = Union{Both,BranchBendersCut}  # not part of the public interface

          export USolveMod
      end

      module SPSolve
          struct Poly end  # public interface
          struct LP end  # public interface
          const USPSolve = Union{Poly,LP}  # not part of the public interface
          export USPSolve
      end

      export SolveMod, SPSolve
  end


  using .Options: SolveMod.USolveMod, SPSolve.USPSolve
  using Parameters
  @with_kw mutable struct OptimizeParameters @deftype String
     solve_mod::USolveMod
     sp_solve::USPSolve
  end
end

In my non MWE-case, I have 7 (out of 32) parameters for my solver that need a dedicated type, instead of two in the MWE (SolveMod and SPSolve). So I was wondering if I could write something like:

using .Options: All Instead of using .Options: SolveMod.USolveMod, SPSolve.USPSolve 3rdClass.Uniontype, 4thClass.Uniontype (etc.)

5 posts - 3 participants