MondayMorningHaskell / haskellings

An automated tutorial to teach you about Haskell!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't Find Imports for Exercises

jhb563 opened this issue · comments

When running an exercise, typically a unit tested exercise, I sometimes find that it cannot locate the imported modules:

Input command:

>> haskellings run Functions1
Couldn't compile : Functions1.hs

/home/jbowen/haskellings/exercises/functions/Functions1.hs:3:1: error:
    Could not find module 'Test.Tasty'
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
3 | import Test.Tasty
  | ^^^^^^^^^^^^^^^^^

... (same for Test.Tasty.HUnit)

This is a consequence of the TODO noted here: https://github.com/MondayMorningHaskell/haskellings/blob/master/src/Config.hs#L127-L128

It is possible to have multiple snapshots that use GHC 8.8.4. One or more of them may not have the appropriate dependencies, particularly tasty and tasty-hunit. As is, the logic does not differentiate between these snapshots and will pick the first one that succeeds.

This logic needs to be tighter, probably by enhancing the GHC Predicate expression to include a search of the directory to ensure common dependencies (tasty, tasty-hunit) are present.

Temporary Workaround 1:

From the project directory, use stack exec with haskellings commands:

>> stack exec -- haskellings run Functions1
>> stack exec -- haskellings watch

By wrapping it in stack, I think the project-wide dependencies get included.

Brute Force Workaround (not recommended in all cases):

If you delete .stack and run stack build from the project again, there will be no conflicting snapshots. Be aware of the drawbacks here:

  1. You will lose custom configurations you may have had (.stack/config.yaml) unless you save them
  2. It will take a while to re-download GHC and re-build the project
  3. All other Haskell projects on your machine will likewise have to re-download GHC.

Should be fixed via #19. Additional dependencies should be added to the requiredLibs list in Config.hs.