Stack Traces in Haskell
Examensarbete för masterexamen
Computer science – algorithms, languages and logic (MPALG), MSc
This thesis presents ideas for how to implement Stack Traces for the Glasgow Haskell Compiler. The goal is to come up with an implementation with such small overhead that organizations do not hesitate to use it for their binaries running in production. Since the implementation is aiming for efficiency it will be heavily tied to only GHC. This work has been made possible thanks to a very recent contribution  that implements debug data for binaries compiled with GHC. Thanks to that contribution, this thesis can almost entirely focus on managing the GHC stack. Three different designs of stack values is presented, they allow creation in constant time and we implement one of these designs. The overhead of these designs can be kept small by utilizing laziness and the special linked list structure of the GHC stack. The other contribution is the work on the Haskell API that is exposed to programmers. We have implemented an API where the Haskell programmer can create the stack value at will and examine its content. Different ways of incorporating stack traces into the catching and throwing mechanism have been analyzed and we have found a rethrowing semantics for Haskell that is backwards compatible, convenient to use and easy to implement in GHC. The design in this paper allows stack values to be first class values.
Data- och informationsvetenskap , Informations- och kommunikationsteknik , Computer and Information Science , Information & Communication Technology