Giving Haskell a promotion (original) (raw)
Related papers
Higher-order type-level programming in Haskell
Proceedings of the ACM on Programming Languages, 2019
Type family applications in Haskell must be fully saturated. This means that all type-level functions have to be first-order, leading to code that is both messy and longwinded. In this paper we detail an extension to GHC that removes this restriction. We augment Haskell’s existing type arrow, |->|, with an unmatchable arrow, | >|, that supports partial application of type families without compromising soundness. A soundness proof is provided. We show how the techniques described can lead to substantial code-size reduction (circa 80%) in the type-level logic of commonly-used type-level libraries whilst simultaneously improving code quality and readability.
Types, Data Abstraction, and Polymorphism
Our objective is to understand the notion of type in programming languages, present a model of typed, polymorphic programming languages that reflects recent research in type theory, and examine the relevance of recent research to the design of practical programming languages. Object-oriented languages provide both a framework and a motivation for exploring the interaction among the concepts of type, data abstraction, and polymorphism, since they extend the notion of type to data abstraction and since type inheritance is an important form of polymorphism. We develop a X-calculus-based model for type systems that allows us to explore these interactions in a simple setting, unencumbered by complexities of production programming languages. The evolution of languages from untyped universes to monomorphic and then polymorphic type systems is reviewed. Mechanisms for polymorphism such as overloading, coercion, subtyping, and parameterization are examined. A unifying framework for polymorphic type systems is developed in terms of the typed A-calculus augmented to include binding of types by quantification as well as binding of values by abstraction. The typed X-calculus is augmented by universal quantification to model generic functions with type parameters, existential quantification and packaging (information hiding) to model abstract data types, and bounded quantification to model subtypes and type inheritance. In this way we obtain a simple and precise characterization of a powerful type system that includes abstract data types, parametric polymorphism, and multiple inheritance in a single consistent framework. The mechanisms for type checking for the augmented X-calculus are discussed. The augmented typed X-calculus is used as a programming language for a variety of illustrative examples. We christen this language Fun because fun instead of X is the functional abstraction keyword and because it is pleasant to deal with. Fun is mathematically simple and can serve as a basis for the design and implementation of real programming languages with type facilities that are more powerful and expressive than those of existing programming languages. In particular, it provides a basis for the design of strongly typed object-oriented languages.
Generic Haskell: Practice and Theory
2003
Generic Haskell is an extension of Haskell that supports the construction of generic programs. These lecture notes describe the basic constructs of Generic Haskell and highlight the underlying theory.
The hierarchical development of a generic type mechanism for functional languages
Computer Languages, 1990
Adoption of a scientific approach to language design, featuring the identification of language design with programming, leads to the advocacy of an explicitly hierarchical approach to language development. Choice of the lambda-calculus as basis of the linguistic hierarchy is determined when "elegance" is the predominant criterion for assessing the quality of designs. The consequence is that the hierarchy is primarily comprised of a family of untyped functional languages. We embark upon the hierarchical development of a quality data type system for such languages, including a powerful mechanism for generic data abstraction, in five stages. We show that the expressiveness of the system, in comparison with the widespread "polymorphic'" typing approach, is well worth the price of the necessarily dynamic checking for type conformance. Applicative (functional) programming Software tools and techniques Extensible languages
Libraries for generic programming in Haskell
2009
These lecture notes introduce libraries for datatype-generic programming in Haskell. We introduce three characteristic generic programming libraries: lightweight implementation of generics and dynamics, extensible and modular generics for the masses, and scrap your boilerplate. We show how to use them to use and write generic programs. In the case studies for the different libraries we introduce generic components of a medium-sized application which assists a student in solving mathematical exercises.
Lecture Notes in Computer Science, 2008
Interface types are a useful concept in object-oriented programming languages like Java or C#. A clean programming style advocates relying on interfaces without revealing their implementation. Haskell's type classes provide a closely related facility for stating an interface separately from its implementation. However, there are situations in which no simple mechanism exists to hide the identity of the implementation type of a type class. This work provides such a mechanism through the integration of lightweight interface types into Haskell. The extension is non-intrusive as no additional syntax is needed and no existing programs are affected. The implementation extends the treatment of higher-rank polymorphism in production Haskell compilers.
Haskell's overlooked object system
Computing Research Repository, 2005
Haskell provides type-class-bounded and parametric polymorphism as opposed to subtype polymorphism,of object-oriented languages such as Java and OCaml. It is a contentious question whether Haskell 98 without extensions, or with common extensions, or with new extensions can fully support conventional object-oriented programming,with encapsulation, mutable state, inheritance, overriding, statically checked implicit and explicit subtyping, and so on. In a first
Comparing approaches to generic programming in Haskell
2007
The last decade has seen a number of approaches to datatype-generic programming: PolyP, Functorial ML,'Scrap Your Boilerplate', Generic Haskell,'Generics for the Masses', and so on. The approaches vary in sophistication and target audience: some propose full-blown programming languages, some suggest libraries, some can be seen as categorical programming methods. In these lecture notes we compare the various approaches to datatype-generic programming in Haskell.
Towards open type functions for Haskell
2007
We report on an extension of Haskell with type(-level) functions and equality constraints. We illustrate their usefulness in the context of phantom types, GADTs and type classes. Problems in the context of type checking are identified and we sketch our solution: a decidable type checking algorithm for a restricted class of type functions. Moreover, functional dependencies are now obsolete: we show how they can be encoded as type functions.
Towards Open Type Functions for Haskell—DRAFT—
2007
We report on an extension of Haskell with type(-level) functions and equality constraints. We illustrate their usefulness in the context of phantom types, GADTs and type classes. Problems in the context of type checking are identified and we sketch our solution: a decidable type checking algorithm for a restricted class of type functions. Moreover, functional dependencies are now obsolete: we show how they can be encoded as type functions. This paper is submitted to the Implementing Functional Languages workshop, Sept 2007 (IFL07).