Skip to main content

Typing Haskell with an Attribute Grammar

  • Conference paper
Advanced Functional Programming

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 3622))

Abstract

A great deal has been written about type systems. Much less has been written about implementing them. Even less has been written about implementations of complete compilers in which all aspects come together. This paper fills this gap by describing the implementation of a series of compilers for a simplified variant of Haskell. By using an attribute grammar system, aspects of a compiler implementation can be described separately and added in a sequence of steps, thereby giving a series of increasingly complex (working) compilers. Also, the source text of both this paper and the executable compilers come from the same source files by an underlying minimal weaving system. Therefore, source and explanation is kept consistent.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. The Glasgow Haskell Compiler (2004), http://www.haskell.org/ghc/

  2. Abadi, M., Cardelli, L.: A Theory of Objects. Springer, Heidelberg (1996)

    Book  Google Scholar 

  3. Baars, A.: Attribute Grammar System. arSystem (2004), http://www.cs.uu.nl/groups/ST/twiki/bin/view/Center/AttributeGramm

  4. Bird, R.S.: Using Circular Programs to Eliminate Multiple Traversals of Data. Acta Informatica 21, 239–250 (1984)

    Article  Google Scholar 

  5. Boquist, U.: Code Optimisation Techniques for Lazy Functional Languages, PhD Thesis. Chalmers University of Technology (1999)

    Google Scholar 

  6. Boquist, U., Johnsson, T.: The GRIN Project: A Highly Optimising Back End For Lazy Functional Languages. In: Selected papers from the 8th International Workshop on Implementation of Functional Languages (1996)

    Google Scholar 

  7. Botlan, D., Le, Remy, D.: ML-F, Raising ML to the Power of System F. In: ICFP (2003)

    Google Scholar 

  8. Damas, L., Milner, R.: Principal type-schemes for functional programs. In: Proceedings of Principles of Programming Languages (POPL), pp. 207–212. ACM, New York (1982)

    Google Scholar 

  9. Damas, L., Milner, R.: Principal type-schemes for functional programs. In: 9th symposium Principles of Programming Languages, pp. 207–212. ACM Press, New York (1982)

    Google Scholar 

  10. Diatchki, I.S., Jones, M.P., Hallgren, T.: A Formal Specification of the Haskell 98 Module System. In: Haskell Workshop, pp. 17–29 (2002)

    Google Scholar 

  11. Dijkstra, A.: EHC Web (2004), http://www.cs.uu.nl/groups/ST/Ehc/WebHome

  12. Dijkstra, A., Swierstra, D.: Explicit implicit parameters. Technical Report UU-CS-2004-059, Institute of Information and Computing Science (2004)

    Google Scholar 

  13. Dijkstra, A., Swierstra, D.: Typing Haskell with an Attribute Grammar (Part I). Technical Report UU-CS-2004-037, Department of Computer Science, Utrecht University (2004)

    Google Scholar 

  14. Faxen, K.-F.: A Static Semantics for Haskell. Journal of Functional Programming 12(4), 295 (2002)

    Article  MathSciNet  Google Scholar 

  15. Gaster, B.R., Jones, M.P.: A Polymorphic Type System for Extensible Records and Variants. Technical Report NOTTCS-TR-96-3, Languages and Programming Group, Department of Computer Science, Nottingham (November 1996)

    Google Scholar 

  16. Hall, C., Hammond, K., Jones, S.P., Wadler, P.: Type Classes in Haskell. ACM TOPLAS 18(2), 109–138 (1996)

    Article  Google Scholar 

  17. Heeren, B., Hage, J., Swierstra, S.D.: Generalizing Hindley-Milner Type Inference Algorithms. Technical Report UU-CS-2002-031, Institute of Information and Computing Science, University Utrecht, Netherlands (2002)

    Google Scholar 

  18. Hindley, J.R.: The principal type-scheme of an object in combinatory logic. Transactions of the American Mathematical Society 146, 29–60 (1969)

    MathSciNet  MATH  Google Scholar 

  19. Johnsson, T.: Attribute grammars as a functional programming paradigm. In: Functional Programming Languages and Computer Architecture, pp. 154–173 (1987)

    Google Scholar 

  20. Jones, M.P.: Typing Haskell in Haskell. In: Haskell Workshop (1999)

    Google Scholar 

  21. Jones, M.P.: Typing Haskell in Haskell (2000), http://www.cse.ogi.edu/~mpj/thih/

  22. Jones, M.P., Jones, S.P.: Lightweight Extensible Records for Haskell. In: Haskell Workshop, number UU-CS-1999-28. Utrecht University, Institute of Information and Computing Sciences (1999)

    Google Scholar 

  23. Kuiper, M.F., Swierstra, S.D.: Using Attribute Grammars to Derive Efficient Functional Programs. In: Computing Science in the Netherlands CSN 1987 (November 1987)

    Google Scholar 

  24. Lämmel, R., Jones, S.P.: Scrap your boilerplate: a practical design pattern for generic programming. In: Types In Languages Design And Implementation, pp. 26–37 (2003)

    Google Scholar 

  25. Laufer, K., Odersky, M.: Polymorphic Type Inference and Abstract Data Types. Technical Report LUC-001, Loyola University of Chicago (1994)

    Google Scholar 

  26. Milner, R.: A theory of type polymorphism in programming. Journal of Computer and System Sciences 17(3) (1978)

    Google Scholar 

  27. Mitchell, J.C., Plotkin, G.D.: Abstract Types Have Existential Type. ACM TOPLAS 10(3), 470–502 (1988)

    Article  Google Scholar 

  28. Odersky, M., Laufer, K.: Putting Type Annotations to Work. In: Principles of Programming Languages, pp. 54–67 (1996)

    Google Scholar 

  29. Odersky, M., Sulzmann, M., Wehr, M.: Type Inference with Constrained Types. In: Fourth International Workshop on Foundations of Object-Oriented Programming, FOOL 4 (1997)

    Google Scholar 

  30. Perry, N.: The Implementation of Practical Functional Programming Languages (1991)

    Google Scholar 

  31. Jones, S.P.: Haskell 98, Language and Libraries, The Revised Report. Cambridge Univ. Press (2003)

    Google Scholar 

  32. Jones, S.P., Shields, M.: Practical type inference for arbitrary-rank types (2004), http://research.microsoft.com/Users/simonpj/papers/putting/index.htm

  33. Jones, S.P.: The Implementation of Functional Programming Languages. Prentice Hall, Englewood Cliffs (1987)

    MATH  Google Scholar 

  34. Pierce, B.C.: Types and Programming Languages. MIT Press, Cambridge (2002)

    MATH  Google Scholar 

  35. Saraiva, J.: Purely Functional Implementation of Attribute Grammars. PhD thesis, Utrecht University (1999)

    Google Scholar 

  36. Shan, C.-c.: Sexy types in action. ACM SIGPLAN Notices 39(5), 15–22 (2004)

    Article  Google Scholar 

  37. Shields, M., Jones, S.P.: First-class Modules for Haskell. In: Ninth International Conference on Foundations of Object-Oriented Languages (FOOL 9), Portland, Oregon (December 2001)

    Google Scholar 

  38. Utrecht University Software Technology Group. UUST library (2004), http://cvs.cs.uu.nl/cgi-bin/cvsweb.cgi/uust/

  39. Swierstra, S.D., Alocer, P.R.A., Saraiava, J.: Designing and Implementing Combinator Languages. In: Swierstra, D., Henriques, P., Oliveira, J. (eds.) Advanced Functional Programming, Third International School, AFP 1998. LNCS, vol. 1608, pp. 150–206. Springer, Heidelberg (1999)

    Google Scholar 

  40. Thompson, S.: Type Theory and Functional Programming. Addison-Wesley, Reading (1991)

    MATH  Google Scholar 

  41. Wadler, P.: Theorems for free! In: 4’th International Conference on Functional Programming and Computer Architecture (September 1989)

    Google Scholar 

  42. Wadler, P.: Deforestation: transforming programs to eliminate trees. Theoretical Computer Science (Special issue of selected papers from 2’nd European Symposium on Programming) 73, 231–248 (1990)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2005 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Dijkstra, A., Swierstra, S.D. (2005). Typing Haskell with an Attribute Grammar. In: Vene, V., Uustalu, T. (eds) Advanced Functional Programming. Lecture Notes in Computer Science, vol 3622. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11546382_1

Download citation

  • DOI: https://doi.org/10.1007/11546382_1

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-28540-3

  • Online ISBN: 978-3-540-31872-9

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics