In his Monad Reader article in Hoogle p.33 , Neil Mitchell advocates combining Haskell projects into a single executable with multiple modes. (The FYI Neil Mitchell CmdArgs library simplifies the process.) Thus, there may be one mode for starting the web server, another mode for querying the database from the command line, etc. Quote:
Provide one executable
Version 3 had four executable programs - one for generating ranking information, one for searching on the command line, one for web searching, and one for conducting regression testing. Version 4 has one executable file that performs all of the above and more, controlled by flags. There are many advantages to providing only one final program - this reduces the likelihood of code breaking without noticing it, it makes the overall file size smaller, without duplicating the Haskell runtime system, it reduces the number of commands that users need to learn. Switching to a single multi-purpose executable seems to be a common topic, which tools like darcs and hpc, based on the same command with multiple modes.
My question is: it is usually considered that in Haskell it is best to put everything in one larger monolithic executable file, instead of, say, following the “Unix philosophy” and creating small independent, interacting Haskell programs that exchange data through a database or text streams ?
I see how the large monolithic program Haskell allows you to better use type safety by distributing the basic data types throughout the system. But standard warnings against large monoliths still seem to apply, including an increased risk of dependency conflicts.
source
share