Menu

module import problem

Help
Song Zhang
2011-09-08
2012-12-06
  • Song Zhang

    Song Zhang - 2011-09-08

    I write some codes in the Real World Haskell chapter 5 SimpleJSON in eclipse I run PrettyJSON using GHCi, it said that  
    C:\Users\vxanica\Haskell Workspace\SimpleJSON\src\PrettyJSON.hs:5:8:
    Could not find module `SimpleJSON':
          Use -v to see a list of the files searched for.
    However I load the same file in WinGHCi it is OK, it said
    Compiling SimpleJSON       ( SimpleJSON.hs, interpreted )
    Compiling PrettyJSON       ( PrettyJSON.hs, interpreted )
    Ok, modules loaded: PrettyJSON, SimpleJSON.
    just don't know the reason
    many thanks

     
  • JP Moresmau

    JP Moresmau - 2011-09-09

    Do you have a cabal file that reference properly the source folders, and all the modules you want to build?

     
  • Song Zhang

    Song Zhang - 2011-09-09

    yes in the cabal file
    name:           SimpleJSON
    version:        0.1
    cabal-version:  >= 1.2
    build-type:     Simple

    executable SimpleJSON
      hs-source-dirs:  src
      main-is:         Main.hs
      build-depends:   base >= 4
      ghc-options:     -Wall
    I think it is OK.

     
  • JP Moresmau

    JP Moresmau - 2011-09-12

    Try to add your modules to your executable via the other-modules directive (or right click on each module, go to module inclusion and check the check boxes)

     
  • Han Joosten

    Han Joosten - 2011-09-12

    As far as I know, cabal does not require an executable to have all the 'other-module' directive in it. I thought it is only for libraries. Why is EclipseFP different in this? 

     
  • JP Moresmau

    JP Moresmau - 2011-09-12

    Mmmhh, I'm not sure, something to do with the default folder in which we run? We probably launch ghci in the project folder, where vxanica launches WinGHCi from the src folder…

     
  • Song Zhang

    Song Zhang - 2011-09-14

    I suppose that the default folder is the project folder, in a new project i have to put the file in the root of the project folder for readFile function  which is in a hs file in src  folder. Same for the dll files since I use glut.dll to plot. I do not know how to set the default project worksapce path like in Visual Studio 2010.
    I am not quite sure what the check boxes refer to.

     
  • Song Zhang

    Song Zhang - 2011-09-14

    I found that there is no red waves under the module I imported, so the editor is happy and can see the module. but it cannot run.

     
  • Song Zhang

    Song Zhang - 2011-09-14

    sorry to post so much.
    I try many times, I really think there a little bit problem here.
    for example I got three files in src folder Glob.hs, GlobRegex.hs,Main.hs
    Glob.hs import GlobRegex file.
    in src folder if I run I will get an error.
    but if I copy the GlobRegex.hs to the root folder of my project
    I can run Glob.hs in src folder
    I think there is a problem with linking and compiling.
    when it is checking, it will checking the files in src folder
    However, when it is linking the modules the files in the root folder are loaded.
    Which means that I have to keep double copies in both src folder and root folder to make the file be imported.
    I am not sure any others encountered a problem like this.

     
  • Song Zhang

    Song Zhang - 2011-09-14

    If I bother you, I am very sorry. I am just a starter. used to use Leksah, but I just prefer eclipse more! Java C Haskell all in one! it is just convenient. thanks.

     
  • JP Moresmau

    JP Moresmau - 2011-09-14

    No problem. I'm not very clear on what you're trying to achieve though. Maybe you could zip your project folder (the source, the cabal file, etc) and send it to me directly. My email is at the bottom of the release notes (https://sourceforge.net/projects/eclipsefp/files/EclipseFP%202%20branch/2.1.0/). Also send instructions on what operations you're trying to do.

     

Log in to post a comment.