= The GHC reading list = Suppose you want to start contributing to GHC: what should you read by way of background? Here is an annotated list. Please add to it as you come across useful material. You can ask questions on `ghc-devs@haskell.org`. People are friendly. See also [wiki:WorkingConventions working on GHC] and [wiki:Contributors GHC contributors]. == General background == * The [wiki:Commentary GHC Commentary] is a Wiki that describes GHC's implementation. It is a Wiki. That means that you can, and should, fix errors and write new chapters. * [http://www.aosabook.org/en/ghc.html The Glasgow Haskell Compiler], in [http://www.aosabook.org/en/index.html The Architecture of Open Source Applications], Volume II, ed Brown & Wilson. This paper gives an up to date (2012) technical overview of GHC. * Simon PJ's [http://research.microsoft.com/~simonpj home page] and [http://research.microsoft.com/en-us/um/people/simonpj/papers/papers.html publications page] have lots of relevant papers. Some key ones appear below but not all. * Simon PJ's books: * [http://research.microsoft.com/en-us/um/people/simonpj/papers/slpj-book-1987/index.htm The Implementation of Functional Programming Languages] * [http://research.microsoft.com/en-us/um/people/simonpj/papers/pj-lester-book/ Implementing Functional Languages: a tutorial] give useful general background. They are not GHC-specific at all, but they have lots of information about functional-language compilers. == Types and type inference == * [http://haskell.org/haskellwiki/Simonpj/Talk:OutsideIn Modular type inference with local assumptions], Simon Peyton Jones, Dimitrios Vytiniotis, Tom Schrijvers, Martin Suzmann, Journal of Functional Programming, 2011. This epic 83-page JFP paper brings together, in a single uniform framework, a series of our earlier papers on type inference for type systems involving local constraints, including GADTs and indexed type families. * [http://research.microsoft.com/en-us/um/people/simonpj/papers/ext-f/ Papers about type equalities in GHC's intermediate language] * ''Equality proofs and deferred type errors'', Simon Peyton Jones, Dimitrios Vytiniotis and Pedro Magalhaes (ICFP 2012). An exploration of what happens when you take equality proofs seriously in a compiler. * ''Giving Haskell a promotion'', Brent Yorgey, Stepanie Weirich, Julien Cretin, Simon Peyton Jones, and Dimitrios Vytiniotis (TLDI 2012). How to (a) add kind polymorphism and (b) promote data types to become data kinds. * ''System F with Type Equality Coercions'', Martin Sulzmann, Manuel Chakravarty, and Simon Peyton Jones (TLDI 2007). The first paper about System FC. * [http://research.microsoft.com/en-us/um/people/simonpj/papers/unboxed-values.ps.Z Unboxed values as first class citizens], SL Peyton Jones and J Launchbury, Functional Programming Languages and Computer Architecture (FPCA'91), Boston, LNCS 523, Springer Verlag, Sept 1991, pp636-666. How unboxed data types work in GHC. Please add: System FC, GADTs, kind polymorphism etc == Optimisations == * [http://research.microsoft.com/en-us/um/people/simonpj/papers/comp-by-trans-scp.ps.gz A transformation-based optimiser for Haskell], SL Peyton Jones and A Santos, Science of Computer Programming 32(1-3), pp3-47, September 1998. Gives an overview of many of the transformations GHC does on Core. Andre's [http://research.microsoft.com/en-us/um/people/simonpj/papers/santos-thesis.ps.gz PhD thesis] gives more details. * [http://research.microsoft.com/en-us/um/people/simonpj/papers/inlining/index.htm Secrets of the GHC inliner], Simon Peyton Jones and Simon Marlow, Journal of Functional Programming 12(4), July 2002, pp393-434. Describes how the Simplifier does inlining. * [http://research.microsoft.com/en-us/um/people/simonpj/papers/deforestation-short-cut.ps.Z A short cut to deforestation], A Gill, SL Peyton Jones, J Launchbury, Proc Functional Programming Languages and Computer Architecture (FPCA'93), Copenhagen, June 1993, pp223-232. The famous foldr/build rule. Andy's [http://research.microsoft.com/en-us/um/people/simonpj/papers/andy-thesis.ps.gz PhD thesis] has more. * [http://research.microsoft.com/en-us/um/people/simonpj/papers/rules.htm Playing by the rules: rewriting as a practical optimisation technique in GHC], Simon Peyton Jones, Andrew Tolmach and Tony Hoare, Haskell Workshop 2001. Describes how RULES work, which are heavily used in GHC. * [https://research.microsoft.com/en-us/um/people/simonpj/papers/spec-constr/spec-constr.pdf Call-pattern Specialisation for Haskell Programs], Simon Peyton Jones, ICFP 2007. Describe the specialisation optimiser. * [http://research.microsoft.com/pubs/67060/float.ps.gz Let-floating: moving bindings to give faster programs], Simon Peyton Jones, Will Partain, and Andre Santos, ICFP 1996. Describe the let floating and full laziness optimisation passes. == Data Parallel Haskell == * [http://www.cse.unsw.edu.au/~chak/papers/data-parallel-haskell.pdf Data Parallel Haskell: a status report], Manuel M. T. Chakravarty, Roman Leshchinskiy, Simon Peyton Jones, Gabriele Keller, and Simon Marlow. , DAMP 2007: Workshop on Declarative Aspects of Multicore Programming, 2007 * [http://www.cse.unsw.edu.au/~chak/papers/fsttcs2008.pdf Harnessing the Multicores: Nested Data Parallelism in Haskell], Simon Peyton Jones, Roman Leshchinskiy, Gabriele Keller, and Manuel M. T. Chakravarty , IARCS Annual Conference on Foundations of Software Technology and Theoretical Computer Science (FSTTCS 2008), IBFI, Schloss Dagstuhl, 2008. * [http://www.cse.unsw.edu.au/~chak/papers/vect-avoid.pdf Vectorisation Avoidance], Gabriele Keller, Manuel M. T. Chakravarty, Roman Leshchinskiy, Ben Lippmeier, and Simon Peyton Jones, Proceedings of ACM SIGPLAN Haskell Symposium 2012, ACM Press, 2012. * [http://www.cse.unsw.edu.au/~chak/papers/replicate.pdf Work Efficient Higher-Order Vectorisation], Ben Lippmeier, Manuel M. T. Chakravarty, Gabriele Keller, Roman Leshchinskiy, and Simon Peyton Jones, The 17th ACM SIGPLAN International Conference on Functional Programming, ACM Press, 2012 == Intermediate Representation of GHC (Core & Related) == * [http://www.haskell.org/ghc/docs/6.10.4/html/ext-core/core.pdf An External Representation for the GHC Core Language] Gives an overview of the semantics and syntax of Core, GHC's internal intermediate representation for Haskell that most of the optimisation work is done on. A good language to understand when starting with GHC. * [http://www.haskell.org/ghc/docs/papers/unboxed-values.ps.gz Unboxed Values as First-Class Citizens], Simon L Peyton Jones and John Launchbury, Conference on Functional Programming Languages and Computer Architecture, September 1991. Describe the design of GHC language and internals for handling machine values and boxing / unboxing them as lazy values. == Code generation and virtual machine == * [http://research.microsoft.com/en-us/um/people/simonpj/papers/eval-apply/index.htm How to make a fast curry: push/enter vs eval/apply], Simon Marlow and Simon Peyton Jones, International Conference on Functional Programming, Snowbird, Sept 2004, pp4-15. * [http://community.haskell.org/~simonmar/papers/ptr-tagging.pdf Faster laziness using dynamic pointer tagging] (Simon Marlow, Alexey Rodriguez Yakushev, Simon Peyton Jones) In ICFP '07: Proceedings of the ACM SIGPLAN international conference on Functional programming, Freiburg, Germany, ACM Press, October 2007 * [http://research.microsoft.com/~simonpj/papers/spineless-tagless-gmachine.ps.gz Implementing lazy functional languages on stock hardware: the Spineless Tagless G-machine], SL Peyton Jones, Journal of Functional Programming 2(2), Apr 1992, pp127-202. The original STG paper but still highly relevant. * [http://www.macs.hw.ac.uk/~dsg/gph/docs/StgSurvival.ps.gz STG Survival Sheet], A poor wee soul, 2001 - This is a very old description of STG. This information is now on the wiki in sections about [http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts RTS] and [http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/GeneratedCode STG]. * [http://research.microsoft.com/en-us/um/people/simonpj/papers/c--/hoopl-haskell10.pdf Hoopl: A Modular, Reusable Library for Dataflow Analysis and Transformation], Norman Ramsey, John Dias, and Simon Peyton Jones. Haskell Symposium 2010 * [http://research.microsoft.com/en-us/um/people/simonpj/papers/c--/ppdp.ps.gz C--: a portable assembly language that supports garbage collection], Simon Peyton Jones, Norman Ramsey, and Fermin Reig. Invited talk at PPDP'99. * [http://research.microsoft.com/en-us/um/people/simonpj/papers/c--/c--exn-pldi.ps.gz A Single Intermediate Language That Supports Multiple Implementations of Exceptions], Norman Ramsey and Simon Peyton Jones, PLDI 2000. == IO and Related == * [https://research.microsoft.com/en-us/um/people/simonpj/papers/marktoberdorf/mark.pdf Tackling the awkward squad: monadic input/output, concurrency, exceptions, and foreign-language calls in Haskell], Simon Peyton Jones. Deals with the incarnation of IO in Haskell and GHC. The history getting to monads, handling exceptions and handling concurrency. * [http://www.haskell.org/ghc/docs/papers/imperative.ps.gz Imperative Functional Programming], Simon Peyton Jones, Philip Wadler. POPL, Jan 1993, pp71-84. Presents Monads as a way of implementing IO in Haskell. * [http://www.haskell.org/ghc/docs/papers/concurrent-haskell.ps.gz Concurrent Haskell], Simon Peyton Jones, Andrew Gordon, Sigbjorn Finne. Deals with the various concurrency constructs in GHC and the Haskell language. E.g., MVars. == The run-time system and garbage collector == * [http://community.haskell.org/~simonmar/papers/multicore-ghc.pdf Runtime Support for Multicore Haskell] (Simon Marlow, Simon Peyton Jones, Satnam Singh) In ICFP '09: Proceeding of the 14th ACM SIGPLAN International Conference on Functional Programming, Edinburgh, Scotland, August 2009 * [http://community.haskell.org/~simonmar/papers/parallel-gc.pdf Parallel Generational-Copying Garbage Collection with a Block-Structured Heap] (Simon Marlow, Tim Harris, Roshan P. James, Simon Peyton Jones) In ISMM '08: Proceedings of the 7th international symposium on Memory management, Tucson, Arizona, ACM, June 2008 * [http://community.haskell.org/~simonmar/papers/multiproc.pdf Haskell on a Shared-Memory Multiprocessor] (Tim Harris, Simon Marlow, Simon Peyton Jones) In Haskell '05: Proceedings of the 2005 ACM SIGPLAN workshop on Haskell, pages 49--61, Tallinn, Estonia, ACM Press, September 2005