ghc search path & Eclipse

Help
vwil
2004-12-07
2012-12-06
  • vwil
    vwil
    2004-12-07

    Hi,

    This is perhaps a stupid question but I'm very new to all this...

    I am testing  Eclipse and the Eclipse Haskell plugin together with
    ghc 6.2. If I try to import a module from my project/src folder,
    ghci doesn't find it (Can't find module 'xy'). How can I automatically modify the search path for ghc, so that I can import my own modules.

    greetings
    Volker

     
    • Leif Frenzel
      Leif Frenzel
      2004-12-07

      Hi Volker,

      (Just to make sure: 'xy' is not a valid name for a module, it should start with an uppercase letter, so maybe that's the problem. If not: )

      Modules in the same folder and in subfolders of the source folders should be found automatically. Compile errors are displayed in the Problems view.

      If you need to add folders to the inlcude path that are outside the workspace, you can do that on the project properties (right-click the project > Properties > Import libraries).

      Hope that helps,
      Ciao,
      Leif

       
    • vwil
      vwil
      2004-12-07

      Hi Leif,

      thanks for your fast response. I am in the very beginning with haskell  playing around with WINHugs before I found   the eclipse plugin, so I have no further experiences with GHC. If i launch ghci manually I can see the same effect, before I can load a module I must changeDir to the directory, a single qualified load isn't enough. Here is the effect:

      C:\ghc\ghc-6.2.2\bin>ghci
         ___         ___ _
        / _ \ /\  /\/ __(_)
      / /_\// /_/ / /  | |      GHC Interactive, version 6.2.2, for Haskell 98.
      / /_\\/ __  / /___| |      http://www.haskell.org/ghc/
      \____/\/ /_/\____/|_|      Type :? for help.

      Loading package base ... linking ... done.
      Prelude> :l C:\workspace\haskell\base\src\orabase.hs
      C:\workspace\haskell\base\src\orabase.hs:
          Can't find module `OracleExport'
          (use -v to see a list of the files searched for)
      Prelude> :cd C:\workspace\haskell\base\src
      Prelude> :l orabase.hs
      Compiling OracleExport     ( ./OracleExport.hs, interpreted )
      Compiling OraBase          ( orabase.hs, interpreted )
      Ok, modules loaded: OraBase, OracleExport.
      *OraBase>

      The same in eclipse, called from the navigator window:

         ___         ___ _
        / _ \ /\  /\/ __(_)
      / /_\// /_/ / /  | |      GHC Interactive, version 6.2.2, for Haskell 98.
      / /_\\/ __  / /___| |      http://www.haskell.org/ghc/
      \____/\/ /_/\____/|_|      Type :? for help.

      Loading package base ... linking ... done.
      c:/workspace/haskell/base/src/Orabase.hs:
          Can't find module `OracleExport'
          (use -v to see a list of the files searched for)
      Prelude>

      Any Idea what goes wrong ?

      greetings
      Volker

       
      • Leif Frenzel
        Leif Frenzel
        2004-12-07

        Ouch, sorry, I overlooked that you were running it in ghci.

        No, you are all right, this is not very well handled by the IDE. You should be able to run several modules by selecting them all and say 'Run as > GHCi session'. Doesn't work, I'll put it on my TODO list. Also, probably the default working directory should be the source path, not the project path ... I really need to find the time and seriously re-work the support for interactive sessions.

        If you have several Haskell files in the source folder, you could select the source folder and say 'Run as > GHCi session'. That should load all files in that folder.

        (The general game is that when you do this, a launch shortcut is created. You find it in the 'Run' toolbar menu (the item with the white triangle in the red circle). You can there  re-run all old lauches that you once created. You can also edit them, by selecting 'Run ...', and then choosing one and editing the settings, e.g. the working directory, on the tabs to the right.)

        Hope it helps,
        Ciao,
        Leif

         
    • vwil
      vwil
      2004-12-07

      YES, this is the way it works! Although not very obvious for a first time eclipse user ;-)
      Keep on good work, I will stay in tune.

      Volker