What is the Haskell syntax to import modules in subdirectories?

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)