1

Update: I am more confused.

If you follow the sequence below, you see that I

  1. attempt to load Either.hs, and get a missing module error
  2. attempt to load Monad.hs, and get a "one module loaded" happy message
  3. attempt again to load Either.hs, and again get a missing module error
  4. 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.
  5. 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

<no location info>: 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

<no location info>: 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

<no location info>: 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

<no location info>: 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?

1
  • Are you still "more confused" after my answer? Feb 10 at 14:02

2 Answers 2

2

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.

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

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

  1. 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

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.

1
  • 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
    Feb 10 at 16:41
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

2
  • 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
    Feb 7 at 1:58
  • 1
    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. Feb 7 at 7:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.