Commit ef958f2a authored by Iustin Pop's avatar Iustin Pop
Browse files

Document some useful Haskell tips

This improves devnotes.rst with some tricks for Haskell development,
and additionally it does two Makefile improvements:

- properly document lib/ as a requirement for
  Constants.hs (but do not require rebuild when updated)
- move HEXTRA at the end of the GHC invocation, so any command line
  options will indeed override the built-in ones (especially -osuf)
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarMichael Hanselmann <>
parent e86f7f65
......@@ -499,9 +499,10 @@ $(HS_ALL_PROGS): %: %.hs $(HS_LIB_SRCS) $(HS_BUILT_SRCS) Makefile
exit 1; \
BINARY=$(@:htools/%=%); $(GHC) --make \
-osuf $$BINARY.o -hisuf $$BINARY.hi $@
-osuf $$BINARY.o -hisuf $$BINARY.hi \
$(HEXTRA) $@
# for the htools/test binary, we need to enable profiling/coverage
htools/test: HEXTRA=-fhpc -Wwarn -fno-warn-missing-signatures \
......@@ -920,7 +921,8 @@ htools/Ganeti/HTools/Version.hs: htools/Ganeti/HTools/ vcs-version
sed -e "s/%ver%/$$VCSVER/" < $< > $@
htools/Ganeti/Constants.hs: htools/Ganeti/ \
lib/ lib/ $(CONVERT_CONSTANTS) \
| lib/
set -e; \
{ cat $< ; PYTHONPATH=. $(CONVERT_CONSTANTS); } > $@
......@@ -59,6 +59,37 @@ different python version)::
./ && \
./configure --prefix=/usr/local --sysconfdir=/etc --localstatedir=/var
Haskell development notes
There are a few things which can help writing or debugging the Haskell
You can run the Haskell linter :command:`hlint` via::
make hlint
This is not enabled by default as it gets many false positives, and
thus the normal output is not “clean”. The above command will generate
both output on the terminal and also a HTML report at
When writing or debugging TemplateHaskell code, it's useful to see
what the splices are converted to. This can be done via::
make HEXTRA="-ddump-splices"
Due to the way TemplateHaskell works, it's not straightforward to
build profiling code. The recommended way is::
make clean
make htools/htools HEXTRA="-osuf .o"
rm htools/htools
make htools/htools HEXTRA="-osuf .prof_o -prof -auto-all"
This will build the binary twice, per the TemplateHaskell
documentation, the second one with profiling enabled.
Packaging notes
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment