Error message Could not find module `Foo'

  • Roland

    Roland - 2013-01-26

    I'm trying to build a very simple Hakell EclipseFP project.
    If I try to run/test it in ghci, I get the error message:
    Could not find module `Foo'

    I do the following:

    1. I create a new eclipseFP project
      Menu: File->New->Haskell Project
      I give the name 'Test' and accept all defaults.

    2. I add a module to my project:
      In the project pane on the left side, I double click on the new Test project.
      The project tree opens.
      I click on the line mit the directory 'src'
      Menu: File->New->Haskell Module
      I give it the name 'Foo' and again I accept all defaults and click Finish

    3. I complete the file Foo.hs:
      module Foo (myfoo) where
      myfoo :: String
      myfoo = "Hello World"

    4. I complete the file Main.hs
      module Main where
      import Foo
      main = putStr myfoo

    5. I try to test my program.
      In the left pane with the tree view I click on Main.hs.
      RightMouseClick->Context Menu->Run as->1 Ghci session

    And now I get the error: Could not find module `Foo'

    If i navigate to my Test directory below the workspace and run ghci in a terminal everything works!

    I use: Ubuntu 12.10, Eclipse 2.2.0, EclipseFP 2.4.2

  • JP Moresmau

    JP Moresmau - 2013-01-27

    I'm sorry, I've run exactly your steps and it works fine:
    [1 of 2] Compiling Foo ( src\Foo.hs, interpreted )
    [2 of 2] Compiling Main ( D:\dev\haskell\jp-github\runtime-New_configuration\Roland\src\Main.hs, interpreted )
    Ok, modules loaded: Main, Foo.
    *Main> main
    Hello World

    Maybe paste in the full output of GHCi. Really, we only launch GHCi with the proper source includes and such, so there's should be much difference.
    If you build your project, does it build without errors? Then after building, can you right click on your project, choose run as haskell application and see "hello world"? This works fine here too.

    • Roland

      Roland - 2013-01-29

      Many thanks for your kind answer:

      I select the file src/Foo.hs and do a 'Run as->1 Ghci session'.
      I get the following console output:

      Foo(Test src) [Haskell interactive session] Foo (Test src)

      GHCi, version 7.4.2: :? for help
      Loading package ghc-prim ... linking ... done.
      Loading package integer-gmp ... linking ... done.
      Loading package base ... linking ... done.
      [1 of 1] Compiling Foo ( /home/roland/workspace/Test/src/Foo.hs, interpreted )
      Ok, modules loaded: Foo.

      I select the file src/Main.hs and do a 'Run as->1 Ghci session'.
      This is the full console output:

      Main(Test src) [Haskell interactive session] Main (Test src)

      GHCi, version 7.4.2: :? for help
      Loading package ghc-prim ... linking ... done.
      Loading package integer-gmp ... linking ... done.
      Loading package base ... linking ... done.

      Could not find module `Foo'
      Use -v to see a list of the files searched for.
      Failed, modules loaded: none.

      Question: Where can I specify the -v option for ghci?

      When I do:

      Menu -> Project -> Build Project

      I get a new title line:

      BuildWrapper output for project test

      and nothing below. It does nothing! There are no additional files!!

      This is the output of a normal terminal window outside of eclipseFP

      roland@Goms:~$ cd workspace
      roland@Goms:~/workspace$ cd Test
      roland@Goms:~/workspace/Test$ cd src
      roland@Goms:~/workspace/Test/src$ ghc -o Test Main.hs Foo.hs
      [1 of 2] Compiling Foo ( Foo.hs, Foo.o )
      [2 of 2] Compiling Main ( Main.hs, Main.o )
      Linking Test ...
      roland@Goms:~/workspace/Test/src$ ./Test
      Hello Worldroland@Goms:~/workspace/Test/src$

      Aside from the missing newline at the end, this little program seems to work.

      This is again the output of a freshly opened normal terminal window outside eclipseFP:

      roland@Goms:~$ cd workspace/Test/src
      roland@Goms:~/workspace/Test/src$ ghci
      GHCi, version 7.4.2: :? for help
      Loading package ghc-prim ... linking ... done.
      Loading package integer-gmp ... linking ... done.
      Loading package base ... linking ... done.
      Prelude> :l Main.hs
      Ok, modules loaded: Main, Foo.
      Prelude Main> main
      Hello WorldPrelude Main>

      I'll reinstall eclipse and eclipseFP!!

  • JP Moresmau

    JP Moresmau - 2013-01-29

    Don't reinstall yet!
    To add -v to ghci, go into Run -> run configurations. under "Haskell interactve session" you'll see your Main module, and in the Arguments tab you can enter -v. Also check in the full arguments that the paths are correct.
    For buildWrapper, it may not be an issue if you don't see anything in the console. Go to preferences -> haskell -> helper executables and there there's a checkbox to turn on debug output
    Refresh your project. Do you see a .dist-buildwrapper folder at the root?
    If you go to your project and type in ghci src/Main.hs, does it work?

    • Roland

      Roland - 2013-01-30

      Ok, this helped!!

      In Menu->Run->Run Configurations under "Haskell interactive" in the arguments pane for my project I see:

      --interactive /home/roland/workspace/Test/src/Main.hs

      Please note, that the file /home/roland/workspace/Test/src/Foo.hs is NOT mentioned!!

      However, to specify my import directory, I can add in the arguments box the following option:


      and then it works!!

      I think, this is a acceptable workaround and allows me to use a lot of the advantages of eclipseFP (eg integrated Hlint)

      Many thanks for your help and also for eclipseFP!

      BTW: This is the contents of my cabal file: (I deleted some empty lines)

      name:           Test
      version:        0.1
      cabal-version:  >=1.2
      build-type:     Simple
      author:         roland
        hs-source-dirs:  src
        build-depends:   base >= 4
        ghc-options:     -Wall
      executable Test
        hs-source-dirs:  src
        main-is:         Main.hs
        build-depends:   base >= 4
        ghc-options:     -Wall
        other-modules:   Foo
  • JP Moresmau

    JP Moresmau - 2013-01-31

    This is not normal. The fact that you get no flags in between --interactive and your source file shows something was wrong. Buildwrapper failed to configure or build your project, probably. I've tried with the exact same cabal file as you and it still works, so there must be something else. Do you have a console saying "Buildwrapper output for project Test"? What does it say when you've enabled debug mode? Otherwise, try to "clean" the project (using the clean menu command in Eclipse), and rebuild it.
    Your cabal file is a bit weird, though. data-files is meant for non Haskell files that you want to include in the distribution, so that's redundant, since the modules are referenced in the other section. Are you sure you want your Main module in your library? You can have Foo in the library, Main as the main-is of the executable, and have the executable depend on the library. that would be clearer. But anyway, as I said, even with that Cabal file, it works here. Check all logs! EclipseFP should add all the proper GHCi flags for you (package dependencies, include folders, etc).

    • Roland

      Roland - 2013-01-31

      After reading your message I did:

      cabal install BuildWrapper --reinstall

      Then I deleted my little test project, and recreated it.
      I got a couple of messages of BuildWrapper in the console window of eclipse. The full arguments text box in the Run Configurations has now a lot of more options like -hide-all-packages -fbuilding-cabal-package and a lot more directories.
      When I run my project in Ghci, it just works.

      Many thanks!!


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks