<p>There is at least two things contributing to the confusion here.</p>
<blockquote>
<ol>
<li>attempt to load Either.hs, and get a missing module error</li>
</ol>
</blockquote>
<p>You don't actually get a missing module error. You get a warning that <code>Week04.Monad</code> is &quot;not listed in your .cabal file's other-modules&quot;. So it warns that you may have problems in the cabal-file but the repl compiles and loads the modules <code>Week04.Monad</code> and <code>Week04.Either</code> just fine. So you get <code>Ok, two modules loaded</code>.</p>
<blockquote>
<ol start="2">
<li>attempt to load Monad.hs, and get a &quot;one module loaded&quot; happy message</li>
</ol>
</blockquote>
<p><code>Week04.Monad</code> has no dependencies so it loads without warning.</p>
<blockquote>
<ol start="3">
<li>attempt again to load Either.hs, and again get a missing module error</li>
</ol>
</blockquote>
<p>Nothing has changed here so this step is exactly the same as step 1 and you get exactly the same result. Why steps 1 and 3 are the same is explained in the description of the <code>:load</code>-command:</p>
<blockquote>
<p>&quot;All previously loaded modules, except package modules, are forgotten.
The new set of modules is known as the target set. Note that :load can
be used without any arguments to unload all the currently loaded
modules and bindings.&quot;.</p>
</blockquote>
<p>The documentation can be found from <a href="https://downloads.haskell.org/%7Eghc/7.0.3/docs/html/users_guide/ghci-commands.html" rel="nofollow noreferrer">GHCi commands</a></p>
<p>The main difference between <code>:load</code> and <code>import</code> is that <code>:load</code> sets the current context in the repl so that you can access the internals of the module that has been loaded as current context. With <code>import</code> you only get access to things that have been exported from the respective module.</p>

CC BY-SA 4.0
2022-02-10T16:41:33.067Z
Thanks, that's helpful. I think what it boils down to is that GHCi is broken issuing an error message that is either unhelpful or unfixable. I have noticed that in other places, eg. "*** WARNING: /Users/jwb/.ghci is writable by someone else, IGNORING!
Suggested fix: execute 'chmod go-w /Users/jwb/.ghci'". Combined with plutus being new and not-yet-finished, me being new to Haskell, Haskell being difficult, and the entire linkage/reference/nesting structure feeling very opaque, I am feeling perpetually lost in a way I have never felt with any other language.
XiTouch
CC BY-SA 4.0
2022-02-08T20:07:51.043Z
2022-02-08T20:24:21.267Z
2022-02-08T20:24:21.267Z
hsteamroller
<p>Does this help? I usually import packages (e.g. Control.Monad) and load local files (src/Week04/Either.hs).</p>
<p><a href="https://www.titanwolf.org/Network/q/c87eb1e3-190b-4f64-ac1f-22ee5b998f0d/y" rel="nofollow noreferrer">https://www.titanwolf.org/Network/q/c87eb1e3-190b-4f64-ac1f-22ee5b998f0d/y</a></p>

CC BY-SA 4.0
2022-02-07T01:58:24.083Z
Unfortunately, no. See my update in the OP. I don't know how the repl can obviously "see" the module but also simultaneously can't see the module.
XiTouch
CC BY-SA 4.0
2022-02-07T07:38:23.497Z
I couldn't find an explanation of what is going on. The warning message is misleading, adding the file to 'other-modules' results in a duplication error. Moreover `:show modules` shows that both modules have been successfully loaded. I get no warning if I do  `:l src/Week04/Either.hs src/Week04/Monad.hs`.
Mihai Codescu
CC BY-SA 4.0
2022-02-06T06:58:30.527Z
2022-02-06T06:58:30.527Z
Mihai Codescu
<p>Update: I am more confused.</p>
<p>If you follow the sequence below, you see that I</p>
<ol>
<li>attempt to load Either.hs, and get a missing module error</li>
<li>attempt to load Monad.hs, and get a &quot;one module loaded&quot; happy message</li>
<li>attempt again to load Either.hs, and again get a missing module error</li>
<li>attempt to import Week04.Monad, and get no error or happy message, but &quot;Week04.Monad&quot; joins other modules before my Prelude prompt. So it sure <em>looks</em> like Week04.Monad is fully available.</li>
<li>attempt to load Either.hs and continue to get a missing module message, even though that module has been imported and is in my prompt.</li>
</ol>
<p>So, still totally confused. If the repl cannot locate a module that has been loaded and imported, how can this error message be made to go away? Or does it mean nothing?</p>
<pre><code>Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default&gt; :l src/Week04/Either.hs

&lt;no location info&gt;: warning: [-Wmissing-home-modules]
    These modules are needed for compilation but not listed in your .cabal file's other-modules: 
        Week04.Monad
Ok, two modules loaded.
Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default Week04.Either&gt; :l src/Week04/Monad.hs
Ok, one module loaded.
Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default Week04.Monad&gt; :l src/Week04/Either.hs

&lt;no location info&gt;: warning: [-Wmissing-home-modules]
    These modules are needed for compilation but not listed in your .cabal file's other-modules: 
        Week04.Monad
Ok, two modules loaded.
Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default Week04.Either&gt; import Week04.Monad
Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default Week04.Monad Week04.Either&gt; :l src/Week04/Either.hs

&lt;no location info&gt;: warning: [-Wmissing-home-modules]
    These modules are needed for compilation but not listed in your .cabal file's other-modules: 
        Week04.Monad
Ok, two modules loaded.
Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default Week04.Monad Week04.Either&gt; 
Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default Week04.Monad Week04.Either&gt; 
</code></pre>
<p>======== Original Question ========</p>
<p>I'm pulling this from a comment thread on another question as it is getting long and merits a separate answer.</p>
<p>In the repl, typically if I enter (as an example)</p>
<blockquote>
<p>:l src/Week04/Either.hs</p>
</blockquote>
<p>I was getting an error (that is fixed and is not the question here). Another helpful Pioneer suggested doing</p>
<blockquote>
<p>import Week04.Either</p>
</blockquote>
<p>However, I get the following error with that</p>
<blockquote><pre>
Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default> import Week04.Either
<p>&lt;no location info&gt;: error:
    Could not load module ‘Week04.Either’
    It is a member of the hidden package ‘plutus-pioneer-program-week04-0.1.0.0’.
    Perhaps you need to add ‘plutus-pioneer-program-week04’ to the build-depends in your .cabal file.
Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default&gt;
</pre></blockquote></p>
<p>I suspect this is either a directory level problem or (more likely) a &quot;compiled vs interpreted&quot; issue but still new enough to be confused. Can anyone clarify exactly how such things should work?</p>

CC BY-SA 4.0
2022-02-10T14:02:40.670Z
Are you still "more confused" after my answer?
hsteamroller
<plutus-pioneer-program><repl>
Difference between "import" and load (as "> :l ")
# Difference between "import" and load (as "> :l ")

(Asked by: username_0 on 2022-02-06)

Update: I am more confused.
If you follow the sequence below, you see that I

attempt to load Either.hs, and get a missing module error
attempt to load Monad.hs, and get a "one module loaded" happy message
attempt again to load Either.hs, and again get a missing module error
attempt to import Week04.Monad, and get no error or happy message, but "Week04.Monad" joins other modules before my Prelude prompt. So it sure looks like Week04.Monad is fully available.
attempt to load Either.hs and continue to get a missing module message, even though that module has been imported and is in my prompt.

So, still totally confused. If the repl cannot locate a module that has been loaded and imported, how can this error message be made to go away? Or does it mean nothing?
Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default> :l src/Week04/Either.hs

: warning: [-Wmissing-home-modules]
    These modules are needed for compilation but not listed in your .cabal file's other-modules: 
        Week04.Monad
Ok, two modules loaded.
Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default Week04.Either> :l src/Week04/Monad.hs
Ok, one module loaded.
Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default Week04.Monad> :l src/Week04/Either.hs

: warning: [-Wmissing-home-modules]
    These modules are needed for compilation but not listed in your .cabal file's other-modules: 
        Week04.Monad
Ok, two modules loaded.
Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default Week04.Either> import Week04.Monad
Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default Week04.Monad Week04.Either> :l src/Week04/Either.hs

: warning: [-Wmissing-home-modules]
    These modules are needed for compilation but not listed in your .cabal file's other-modules: 
        Week04.Monad
Ok, two modules loaded.
Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default Week04.Monad Week04.Either> 
Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default Week04.Monad Week04.Either> 

======== Original Question ========
I'm pulling this from a comment thread on another question as it is getting long and merits a separate answer.
In the repl, typically if I enter (as an example)

:l src/Week04/Either.hs

I was getting an error (that is fixed and is not the question here). Another helpful Pioneer suggested doing

import Week04.Either

However, I get the following error with that

Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default> import Week04.Either
: error:
    Could not load module ‘Week04.Either’
    It is a member of the hidden package ‘plutus-pioneer-program-week04-0.1.0.0’.
    Perhaps you need to add ‘plutus-pioneer-program-week04’ to the build-depends in your .cabal file.
Prelude Data.Char Text.Read Plutus.Trace.Emulator Data.Default>

I suspect this is either a directory level problem or (more likely) a "compiled vs interpreted" issue but still new enough to be confused. Can anyone clarify exactly how such things should work?

**Tags:** plutus-pioneer-program, repl
> **Comments:**
> **username_1**: Are you still "more confused" after my answer?  

---

## 2 answers

### Answer by username_1 on 2022-02-08. Score: 2 | Accepted answer

There is at least two things contributing to the confusion here.

> 1. attempt to load Either.hs, and get a missing module error

You don't actually get a missing module error. You get a warning that `Week04.Monad` is "not listed in your .cabal file's other-modules". So it warns that you may have problems in the cabal-file but the repl compiles and loads the modules `Week04.Monad` and `Week04.Either` just fine. So you get `Ok, two modules loaded`.

> 2. attempt to load Monad.hs, and get a "one module loaded" happy message

`Week04.Monad` has no dependencies so it loads without warning.

> 3. attempt again to load Either.hs, and again get a missing module error

Nothing has changed here so this step is exactly the same as step 1 and you get exactly the same result. Why steps 1 and 3 are the same is explained in the description of the `:load`-command:

> "All previously loaded modules, except package modules, are forgotten.
> The new set of modules is known as the target set. Note that :load can
> be used without any arguments to unload all the currently loaded
> modules and bindings.".

The documentation can be found from [GHCi commands](https://downloads.haskell.org/%7Eghc/7.0.3/docs/html/users_guide/ghci-commands.html)

The main difference between `:load` and `import` is that `:load` sets the current context in the repl so that you can access the internals of the module that has been loaded as current context. With `import` you only get access to things that have been exported from the respective module.

> **Comments:**
> **username_0**: Thanks, that's helpful. I think what it boils down to is that GHCi is broken issuing an error message that is either unhelpful or unfixable. I have noticed that in other places, eg. "*** WARNING: /Users/jwb/.ghci is writable by someone else, IGNORING! Suggested fix: execute 'chmod go-w /Users/jwb/.ghci'". Combined with plutus being new and not-yet-finished, me being new to Haskell, Haskell being difficult, and the entire linkage/reference/nesting structure feeling very opaque, I am feeling perpetually lost in a way I have never felt with any other language.  

---

### Answer by username_2 on 2022-02-06. Score: 0

Does this help? I usually import packages (e.g. Control.Monad) and load local files (src/Week04/Either.hs).

<https://www.titanwolf.org/Network/q/c87eb1e3-190b-4f64-ac1f-22ee5b998f0d/y>

> **Comments:**
> **username_0**: Unfortunately, no. See my update in the OP. I don't know how the repl can obviously "see" the module but also simultaneously can't see the module.  
> **username_2**: I couldn't find an explanation of what is going on. The warning message is misleading, adding the file to 'other-modules' results in a duplication error. Moreover `:show modules` shows that both modules have been successfully loaded. I get no warning if I do  `:l src/Week04/Either.hs src/Week04/Monad.hs`.  

---

