Build systems that know when to recompile -- revised

Your particular example of adding an optional argument will always need a recompilation of the calling code because adding an optional argument still changes the .mod file and the underlying binary call (even if your calling code does not need to change).

The legacy Haskell implementation of fpm ('haskell-fpm') is able to determine if a module ABI has changed since it cleverly (and correctly) defines module dependencies based on the .mod module files. The underlying build system Shake uses file hashes to determine if dependencies have changed; therefore if a .mod file is rewritten but unchanged in contents, then the API/ABI can be considered unchanged and hence dependents do not need recompiling. You can still download the Haskell implementation of fpm here (fpm-haskell-0.1.3-*-x86_64).

For reasons of parsimony the active development version of fpm does not define dependencies in the same manner (since module/submodule filenames are compiler dependent) and will conservatively rebuild all dependents if a module source file changes.

4 Likes