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.
Keywords
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
The Glasgow Haskell Compiler (2004), http://www.haskell.org/ghc/
Abadi, M., Cardelli, L.: A Theory of Objects. Springer, Heidelberg (1996)
Baars, A.: Attribute Grammar System. arSystem (2004), http://www.cs.uu.nl/groups/ST/twiki/bin/view/Center/AttributeGramm
Bird, R.S.: Using Circular Programs to Eliminate Multiple Traversals of Data. Acta Informatica 21, 239–250 (1984)
Boquist, U.: Code Optimisation Techniques for Lazy Functional Languages, PhD Thesis. Chalmers University of Technology (1999)
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)
Botlan, D., Le, Remy, D.: ML-F, Raising ML to the Power of System F. In: ICFP (2003)
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)
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)
Diatchki, I.S., Jones, M.P., Hallgren, T.: A Formal Specification of the Haskell 98 Module System. In: Haskell Workshop, pp. 17–29 (2002)
Dijkstra, A.: EHC Web (2004), http://www.cs.uu.nl/groups/ST/Ehc/WebHome
Dijkstra, A., Swierstra, D.: Explicit implicit parameters. Technical Report UU-CS-2004-059, Institute of Information and Computing Science (2004)
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)
Faxen, K.-F.: A Static Semantics for Haskell. Journal of Functional Programming 12(4), 295 (2002)
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)
Hall, C., Hammond, K., Jones, S.P., Wadler, P.: Type Classes in Haskell. ACM TOPLAS 18(2), 109–138 (1996)
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)
Hindley, J.R.: The principal type-scheme of an object in combinatory logic. Transactions of the American Mathematical Society 146, 29–60 (1969)
Johnsson, T.: Attribute grammars as a functional programming paradigm. In: Functional Programming Languages and Computer Architecture, pp. 154–173 (1987)
Jones, M.P.: Typing Haskell in Haskell. In: Haskell Workshop (1999)
Jones, M.P.: Typing Haskell in Haskell (2000), http://www.cse.ogi.edu/~mpj/thih/
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)
Kuiper, M.F., Swierstra, S.D.: Using Attribute Grammars to Derive Efficient Functional Programs. In: Computing Science in the Netherlands CSN 1987 (November 1987)
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)
Laufer, K., Odersky, M.: Polymorphic Type Inference and Abstract Data Types. Technical Report LUC-001, Loyola University of Chicago (1994)
Milner, R.: A theory of type polymorphism in programming. Journal of Computer and System Sciences 17(3) (1978)
Mitchell, J.C., Plotkin, G.D.: Abstract Types Have Existential Type. ACM TOPLAS 10(3), 470–502 (1988)
Odersky, M., Laufer, K.: Putting Type Annotations to Work. In: Principles of Programming Languages, pp. 54–67 (1996)
Odersky, M., Sulzmann, M., Wehr, M.: Type Inference with Constrained Types. In: Fourth International Workshop on Foundations of Object-Oriented Programming, FOOL 4 (1997)
Perry, N.: The Implementation of Practical Functional Programming Languages (1991)
Jones, S.P.: Haskell 98, Language and Libraries, The Revised Report. Cambridge Univ. Press (2003)
Jones, S.P., Shields, M.: Practical type inference for arbitrary-rank types (2004), http://research.microsoft.com/Users/simonpj/papers/putting/index.htm
Jones, S.P.: The Implementation of Functional Programming Languages. Prentice Hall, Englewood Cliffs (1987)
Pierce, B.C.: Types and Programming Languages. MIT Press, Cambridge (2002)
Saraiva, J.: Purely Functional Implementation of Attribute Grammars. PhD thesis, Utrecht University (1999)
Shan, C.-c.: Sexy types in action. ACM SIGPLAN Notices 39(5), 15–22 (2004)
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)
Utrecht University Software Technology Group. UUST library (2004), http://cvs.cs.uu.nl/cgi-bin/cvsweb.cgi/uust/
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)
Thompson, S.: Type Theory and Functional Programming. Addison-Wesley, Reading (1991)
Wadler, P.: Theorems for free! In: 4’th International Conference on Functional Programming and Computer Architecture (September 1989)
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)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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)