How can I load a module into another module using Elixir language?

Hideshi Ogoshi

I'm having hard time to load a module into another module using Elixir language.

For example, I have 2 files shown below:

a.ex

defmodule A do
  def a do
    IO.puts "A.a"
  end
end

b.ex

defmodule B do
  require A

  def b do
    IO.puts "B.b"
    A.a
  end
end

B.b

I tried to execute b.ex. Then I got error shown below:

$elixir b.ex
** (CompileError) b.ex:2: module A is not loaded and could not be found
TheStoneFox

In your file b.ex remove the B.b from the last line

Then in your project directory run Iex like so

iex -S mix

This will load iex and load your modules correcly

Then you can just do B.b

and you'll see:

B.b
A.a
:ok

Also, make sure your a.ex and b.ex files are in the lib/ directory of your elixir project

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I refer to a module variable in a function without referring to its module in Elixir 1.0.3? In its parent scope?

From Dev

How can I use an Ada module in a Perl program using XS?

From Dev

How Can I "Inherit" a Ruby Module to Create Another Module?

From Dev

How can I improve CPU utilization when using the multiprocessing module?

From Dev

How can i pass value from one angular module another Module?

From Dev

How can I send cookie using NodeJs request GET module?

From Dev

How can I call another module controller inside my controller using CI3 + HMVC?

From Dev

How can I get a test resource from another module

From Dev

How can I bypass kivy module error: ImportError: DLL load failed: The specified module could not be found?

From Dev

How module can use resources of another module using gradle multi-module

From Dev

how can i import class from another module maven

From Dev

How can I target a module?

From Dev

How can I do ordinal regression using the mord module in python?

From Dev

How do I load a module to PulseAudio server?

From Dev

How do I permanently load a kernel module?

From Dev

How can I simplify this module?

From Dev

How to load Module from another Angular Project?

From Dev

How do I load a module to PulseAudio server?

From Dev

How do I permanently load a kernel module?

From Dev

How can I load a module at runtime?

From Dev

How can I configure options using the traceur module on nodejs

From Dev

How can I improve CPU utilization when using the multiprocessing module?

From Dev

How to load a module before another module loads?

From Dev

How can I use a controller of one module in another module?

From Dev

how can i import class from another module maven

From Dev

How can I do ordinal regression using the mord module in python?

From Dev

How can I run Redix in supervision tree in phoenix elixir chat app and access from different module

From Dev

Using a module inside another module

From Dev

How can I use a module as a stand-alone CLI and also as a submodule for another module (API)?

Related Related

  1. 1

    How can I refer to a module variable in a function without referring to its module in Elixir 1.0.3? In its parent scope?

  2. 2

    How can I use an Ada module in a Perl program using XS?

  3. 3

    How Can I "Inherit" a Ruby Module to Create Another Module?

  4. 4

    How can I improve CPU utilization when using the multiprocessing module?

  5. 5

    How can i pass value from one angular module another Module?

  6. 6

    How can I send cookie using NodeJs request GET module?

  7. 7

    How can I call another module controller inside my controller using CI3 + HMVC?

  8. 8

    How can I get a test resource from another module

  9. 9

    How can I bypass kivy module error: ImportError: DLL load failed: The specified module could not be found?

  10. 10

    How module can use resources of another module using gradle multi-module

  11. 11

    how can i import class from another module maven

  12. 12

    How can I target a module?

  13. 13

    How can I do ordinal regression using the mord module in python?

  14. 14

    How do I load a module to PulseAudio server?

  15. 15

    How do I permanently load a kernel module?

  16. 16

    How can I simplify this module?

  17. 17

    How to load Module from another Angular Project?

  18. 18

    How do I load a module to PulseAudio server?

  19. 19

    How do I permanently load a kernel module?

  20. 20

    How can I load a module at runtime?

  21. 21

    How can I configure options using the traceur module on nodejs

  22. 22

    How can I improve CPU utilization when using the multiprocessing module?

  23. 23

    How to load a module before another module loads?

  24. 24

    How can I use a controller of one module in another module?

  25. 25

    how can i import class from another module maven

  26. 26

    How can I do ordinal regression using the mord module in python?

  27. 27

    How can I run Redix in supervision tree in phoenix elixir chat app and access from different module

  28. 28

    Using a module inside another module

  29. 29

    How can I use a module as a stand-alone CLI and also as a submodule for another module (API)?

HotTag

Archive