Build, cabal and tooling
Twelve lessons on the build: a Haskell project with cabal, offline; a library, an executable and a test suite in one .cabal file; the GHC flags, the Core that -ddump-simpl prints, and the profiling libraries this image does not have. The debugger follows, in GHCi and in Debug.Trace, then the language editions and the old code they explain, and a run timed five times.
6.1
A Cabal project, offline
cabal init in a folder, the .cabal file, cabal build --offline, what needs the network
Open
6.2
A library, an executable and a test suite
library, executable, test-suite exitcode-stdio-1.0, boot libraries only
Open
6.3
Running the test suite
cabal test --offline, the exit status of a suite, a failing suite
Open
6.4
GHC flags
-O0, -O1, -O2, -Wall, -Werror, -fno-code, -v, -ddump-timings
Open
6.5
Reading -ddump-simpl
-ddump-simpl, -dsuppress-all, a tiny function and its Core, what to look for
Open
6.6
Profiling and why it is not here
-prof and the real error, the profiling libraries a system package would add
Open
6.7
Debugging in GHCi
:break, :continue, :step, :trace, :print, a breakpoint on a function
Open
6.8
Debug.Trace
trace, traceShow, traceM, why the order of output surprises, when to delete it
Open
6.9
gdb and a Haskell binary
-g, a breakpoint in the RTS, why gdb shows little of a lazy program, what to use instead
Open
6.10
Haskell 2010 against GHC2021
default-language, the extensions GHC2021 turns on, Haskell2010 code
Open
6.11
Reading old Haskell
String everywhere, Data.Map as Map, fail in a monad, the AMP change, an old module modernised
Open
6.12
Measuring performance
/usr/bin/time, a warm-up run, five runs, min and median, +RTS -s, the machine line
Open