How to organize files in Haskell programs?
-
05-07-2019 - |
Question
I've just started playing around in Haskell. After years of Ruby, I got used to a file organization that's used by Ruby on Rails or Rugui.
Are there any guidelines, best practices, or maybe even frameworks about file-organization in Haskell programs?
("Learn you a Haskell" & "Real World Haskell" don't really handle this issue.)
Solution
haskell.org defines two file and directory layouts that may be helpful, along with some tool guidance.
- A minimal project layout is based on Hnop.
- A larger-scale structure for bigger projects.
OTHER TIPS
The main constraint is that hierarchical module names must have hierarchical directory layout.
So Data.Map.Fast goes into Data/Map/Fast.hs
After that, decompose your programs and libraries into logical units, in separate modules, and let dependency resolution resolve the modules as needed.