Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
[...]
like image 208
epsilonhalbe Avatar asked Mar 23 '26 21:03

epsilonhalbe


2 Answers

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.

like image 93
vivian Avatar answered Mar 25 '26 10:03

vivian


No need to set anything. Just cd into the root directory before invoking GHCi:

ghci AlgTop/Functions.hs
like image 28
Dominic Mulligan Avatar answered Mar 25 '26 11:03

Dominic Mulligan