Epic—A Library for Generating Compilers

  • Edwin Brady
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7193)


Compilers for functional languages, whether strict or non-strict, typed or untyped, need to handle many of the same problems, for example thunks, lambda lifting, optimisation, garbage collection, and system interaction. Although implementation techniques are by now well understood, it remains difficult for a new functional language to exploit these techniques without either implementing a compiler from scratch, or attempting to fit the new language around another existing compiler. Epic is a compiled functional language which exposes functional compilation techniques to a language implementor, with a Haskell API. In this paper we describe Epic and outline how it may be used to implement a high level language compiler, illustrating our approach by implementing compilers for the λ-calculus and a dynamically typed graphics language.


Garbage Collection Abstract Syntax High Level Language Functional Language Epic Expression 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Augustsson, L.: Cayenne - a language with dependent types. In: Proc. 1998 International Conf. on Functional Programming (ICFP 1998), pp. 239–250 (1998)Google Scholar
  2. 2.
    Benke, M.: Alonzo — a compiler for Agda, Talk at Agda Implementors Meeting 6 (2007)Google Scholar
  3. 3.
    Boehm, H.-J., Demers, A.J.: Xerox Corporation Silicon Graphic, and Hewlett-Packard Company. A garbage collector for C and C++ (2001)Google Scholar
  4. 4.
    Brady, E.: Practical Implementation of a Dependently Typed Functional Programming Language. PhD thesis, University of Durham (2005)Google Scholar
  5. 5.
    Brady, E.: Idris — Systems programming meets full dependent types. In: PLPV, pp. 43–54 (2011)Google Scholar
  6. 6.
    Brady, E., Hammond, K.: Scrapping your inefficient engine: using partial evaluation to improve domain-specific language implementation. In: ICFP 2010: Proceedings of the 15th ACM SIGPLAN International Conference on Functional Programming, pp. 297–308. ACM, New York (2010)CrossRefGoogle Scholar
  7. 7.
    Chapman, J., Dagand, P.-E., McBride, C., Morris, P.: The gentle art of levitation. In: ICFP 2010: Proceedings of the 15th ACM SIGPLAN International Conference on Functional Programming, pp. 3–14. ACM, New York (2010)CrossRefGoogle Scholar
  8. 8.
    Lattner, C.: LLVM: An infrastructure for multi-stage optimization. Master’s thesis, Computer Science Dept. University of Illinois at Urbana-Champaign (December 2002)Google Scholar
  9. 9.
    Leijen, D.: LVM, the Lazy Virtual Machine. Technical Report UU-CS-2004-05, Institute of Information and Computing Sciences, Utrecht University (August 2005)Google Scholar
  10. 10.
    Letouzey, P.: A New Extraction for Coq. In: Geuvers, H., Wiedijk, F. (eds.) TYPES 2002. LNCS, vol. 2646, pp. 200–219. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  11. 11.
    Löh, A., McBride, C., Swierstra, W.: A tutorial implementation of a dependently typed lambda calculus. Fundam. Inform. 102(2), 177–207 (2010)zbMATHGoogle Scholar
  12. 12.
    Marlow, S., Peyton Jones, S.: How to make a fast curry: push/enter vs eval/apply. In: International Conference on Functional Programming, Snowbird, pp. 4–15 (2004)Google Scholar
  13. 13.
    Mitchell, N.: Rethinking supercompilation. In: Proceedings of the 15th ACM SIGPLAN International Conference on Functional Programming, ICFP 2010, pp. 309–320. ACM, New York (2010)CrossRefGoogle Scholar
  14. 14.
    Norell, U.: Towards a practical programming language based on dependent type theory. PhD thesis, Chalmers University of Technology (September 2007)Google Scholar
  15. 15.
    Peyton Jones, S.: Implementing lazy functional languages on stock hardware – the Spineless Tagless G-machine. Journal of Functional Programming 2(2), 127–202 (1992)zbMATHCrossRefGoogle Scholar
  16. 16.
    Jones, S.L.P., Nordin, T., Oliva, D.: C–: A Portable Assembly Language. In: Clack, C., Hammond, K., Davie, T. (eds.) IFL 1997. LNCS, vol. 1467, pp. 1–19. Springer, Heidelberg (1998)CrossRefGoogle Scholar
  17. 17.
    Pfenning, F., Elliot, C.: Higher-order abstract syntax. In: Proceedings of the ACM SIGPLAN 1988 Conference on Programming Language Design and Implementation, PLDI 1988, pp. 199–208. ACM, New York (1988)CrossRefGoogle Scholar
  18. 18.
    Smetsers, S., Nöcker, E., van Groningen, J., Plasmeijer, R.: Generating Efficient Code for Lazy Functional Languages. In: Hughes, J. (ed.) FPCA 1991. LNCS, vol. 523, pp. 592–617. Springer, Heidelberg (1991)CrossRefGoogle Scholar
  19. 19.
    Terei, D.A., Chakravarty, M.M.: An LLVM backend for GHC. In: Proceedings of the Third ACM Haskell Symposium, Haskell 2010, pp. 109–120. ACM, New York (2010)CrossRefGoogle Scholar
  20. 20.
    Wadler, P., Findler, R.B.: Well-Typed Programs Can’t Be Blamed. In: Castagna, G. (ed.) ESOP 2009. LNCS, vol. 5502, pp. 1–16. Springer, Heidelberg (2009)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2012

Authors and Affiliations

  • Edwin Brady
    • 1
  1. 1.University of St AndrewsScotland/UK

Personalised recommendations