I'm currently trying to do a Haskell project using the Test Driven Development methodology. In Java, we can create a nicely structured project containing src and bin folders, then there are main and test folders for unit testing with JUnit. I was just wondering is there a standard way to get such a structure in Haskell? A folder for source a folder for binary, and in the source folder two folders one for testing one for main source.
To build your project, Stack uses a project-level configuration file, named stack. yaml , in the root directory of your project as a sort of blueprint. That file contains a reference, called a resolver, to the snapshot which your package will be built against.
If you have installed the Haskell Platform, open a terminal and type ghci (the name of the executable of the GHC interpreter) at the command prompt. Alternatively, if you are on Windows, you may choose WinGHCi in the Start menu. And you are presented with a prompt.
My reference is alway Structure of a Haskell project and How to write a Haskell program which spell out some defaults which the community more or less seems to follow. It has worked well for me so far but my projects have not been very large as of yet.
What is suggested in Structure of a Haskell project sounds similar to what you have outlined in your post with a few minor modifications like the testing folder is in the same directory as the src folder.
Edit:
cabal init
will generate a minimal amount for you including the cabal file with relevant dependencies if you have a any files with imports at least. It is a great start but only part of what you are looking for.
Ideally as a project grows the cabal file and directory hierarchy would be automatically kept up to date, I am unaware of any tool made public that will do this though. It is on my maybe one day list as I am sure it s for many others.
-odir
and -hidir
can be used with ghc to put the *.o and *.hi files in separate directories. You can read more in GHC user guide's section on separate compilation)
Edit2:
Other relevant/overlapping posts:
The modern answer to this is to use The Haskell Tool Stack. This will structure the project for you using sane defaults.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With