Search code examples
haskellimportmoduleproject-structure

Haskell module not found. What is wrong with my project's file structure?


I have a problem with my project structure:

pic-analysis-0.1/AlgTop/Data.hs
                        Functions.hs
                 PNGModify.hs
                 Main.hs

Data.hs:

module AlgTop.Data (…) where

Functions.hs:

module AlgTop.Functions (…) where
import AlgTop.Data

The AlgTop.Functions module doesn't find AlgTop.Data.

I compared my project structure approach with that of ansi-terminal on Hackage (see below), but I couldn't spot any difference. What am I doing wrong?

ansi-terminal-xxx/System/Console/ANSI/Common.hs
                                     /Unix.hs
                                     /…

Common.hs:

module System.Console.ANSI.Common where

Unix.hs:

module System.Console.ANSI.Unix (…) where
import System.Console.ANSI.Common

Error message:

[...]
*** Chasing dependencies:
Chasing modules from: *Functions.hs

Functions.hs:9:8:
    Could not find module `AlgTop.Data':
      locations searched:
        AlgTop/Data.hs
        AlgTop/Data.lhs
[...]

Solution

  • If you are using ghci it is probably that you need to :set -i/.../pic-analysis-0.1. That is, include the root directory of your module hierarchy.