Haskell is great: Building, tracing, debugging, profiling, .. and all that

Martin Sulzmann

Overview

This is largely work in progress. You find here some links that cover building, tracing, debugging and profiling Haskell programs. You also find some subjective thoughts on why Haskell is such a great language.

Haskell is such a great language

Personal notes

Haskell is fun!

Haskell has many cool type extensions. This can be overwhelming for the novice programmer.

Haskell has inspired many other languages. For example, Rust traits pretty much correspond to Haskell type classes.

Some online resources

Main Haskell reference

Haskell wiki reference

Why Haskell matters

Haskell is a great language to implement other langauges

Haskell in industry. Some company in Karlsruhes that uses Haskell. Haskell used in financial services

Building

GHC is the compiler and interactive environment for writing Haskell programs.

Why are there not other compilers for Haskell out there? There are some but they don't support all the GHC Haskell features.

Here is a comprehensive guide How to write a Haskell program.

Any language needs a good build tool. For Haskell, cabal used to be the main build tool. There is now also stack that seems to becoming more popular (has a docker integration). [What is the difference between Cabal and Stack?)(https://stackoverflow.com/questions/30913145/what-is-the-difference-between-cabal-and-stack)

Tracing

See Debug.Trace

Here is a simple use case.

 module Main where
import Debug.Trace

fib :: Int -> Int
fib 0 = 0
fib 1 = 1
fib n = trace ("n: " ++ show n) $ fib (n - 1) + fib (n - 2)

main = putStrLn $ "fib 4: " ++ show (fib 4)

We find that

*Main> main
fib 4: n: 4
n: 3
n: 2
n: 2
3

Debugging with ghc and ghci

See here

Profiling for ghc

See here