What is Haskell's syntax for importing modules in another directory?
I'm getting started with Haskell and want to practice writing simple functions TDD style with HUnit. I'm having trouble figuring out how to structure my files, though. The example that comes with HUnit seems to be a flat directory structure.
I'd like to have my tests and HUnit code in a different folder than my actual code. I'd appreciate a quick example import statement and a suggestion as to how I might structure my files.
If it matters, I'm using GHCi and NotePad++ to do my coding right now.
You don't actually do it from the Haskell source code; instead you tell the compiler where to look. The usual method is in the .cabal file. See the cabal user guide for details. You want the "hs-source-dirs" parameter.
Alternatively you can pass the path directly to the compiler. However, Cabal is the better method.
Each pathname in the "hs-source-dirs" parameter specifies a root of a module hierarchy. Basically if you import a module called "Data.Foo.Bar" then the compiler looks for a file with the relative pathname "Data/Foo/Bar.hs" in each directory given by "hs-source-dirs" and imports the first one it finds.