Haskell Types with Added Value

Lead Research Organisation: University of Strathclyde
Department Name: Computer and Information Sciences

Abstract

Good ideas, like lightning, take the most conductive path to earth. This one-year project takes advantage of fresh technological insights to narrow the spark-gap from theoretical research to the programming mainstream. In the last decade, dependent types --- capturing relative notions of data validity --- have jumped from logics and proof systems to programming. Prototype languages such as Cayenne, ATS, Agda and our own Epigram teach us how to characterize data precisely, but none has a coherent treatment of interaction in applications. This project will bring the basics of dependent types to application development now, not via a prototype, but with Haskell, a mature functional programming language with growing traction, thanks to the Glasgow Haskell Compiler (GHC), now developed under the Microsoft aegis. To make this jump, we must give practical answers to theoretical questions about the mathematical structures which underpin interactive and distributed systems. We must take the blackboard to the motherboard.

The tool which enables this project is our GHC preprocessor, the Strathclyde Haskell Enhancement (SHE), which mechanizes a partial translation from 'dependently typed Haskell' to Haskell as it stands. Up and running, SHE has already delivered the basics of our approach, leading to an article accepted in 2011 by the Journal of Functional Programming, and spurring deeper investigation of both the mathematics of dependently typed interaction and the engineering challenge of scaling up. Through theoretical research, library design and case study, we shall deliver progress across this spectrum through papers and open source software. GHC is adopting our functionality, but we do not need to wait. SHE can sustain low-cost exploration, putting an effective toolkit in users' hands now, as well as informing the future prospectuses both for dependent types in Haskell and for programming interaction in the next generation of functional languages. Haskellers recognize the need: Microsoft currently funds a PhD at Strathclyde on numerical dependency in Haskell types.

This project is, then, a double fix: it imports dependent types from tomorrow's languages to today's, and it allows us to guide tomorrow's dependently typed languages towards principled approaches to production software. We have proven track records in theoretical research and professional software development, key ideas to change programming for the better, and the skills to deliver world-leading research.

Planned Impact

This project seeks to deliver useful and usable programming technology based on novel techniques and original theoretical research, via the SHE preprocessor for the functional programming language Haskell. SHE will achieve impact outside academia by putting tools for productivity with precision in the hands of programmers: SHE already has this impact on our own software projects, here at Strathclyde, notably the implementation of Epigram. The project is focused on library design, packaging the key abstractions for systematic deployment. Our case studies will show the new technology in effective action and provide examples that other programmers can readily adapt.

Our primary impact is a contribution to the knowledge base, with scientific advances and new software techniques made available and ready to use for a significant and growing community of software professionals. We shall remain active in promoting uptake: new knowledge for the field will become new skills for people, as we equip them to face complex issues in modern applications development with precise and modular technology. Our longer term agenda impacts on society and the economy by making it increasingly feasible, on a technical level, to insist on higher standards of acceptable software behaviour, stronger security policies, clearer articulation of component capabilities, and more precise compliance with agreed protocols. By expressing more of `the rules of the game' in types, we shift more quality assurance responsibility into the basic discipline enforced by the compiler. Our libraries and case studies will show that it is feasible to work effectively to that high level of assurance, and thus reasonable to demand it!

Our work will reach Haskell programmers directly, as our preprocessor is already available and the libraries we develop in this project will be distributed with a suitable open source licence. We have a track record in attracting programmers to fresh ideas. We pursue uptake by participating in the online community and engaging with practitioners and their real world problems at first hand. It is not enough to write academic papers!

Moreover, we shall continue to work with the designers of the Glasgow Haskell Compiler to standardise our technology and techniques in the standard Haskell language and libraries, thus delivering the standard of support needed for industrial-strength deployment. The work to make GHC absorb SHE has already started!

This project addresses a real software problem: in our world of multiple communicating devices, we need reliable ways to express interfaces for meaningful communication and enforce that components respect those interfaces. We seek new programming language technology to cope with the increasing complexity of our computing environments. If we can bring about a step-change in what can feasibly be achieved with Haskell, we shall raise the quality assurance bar for everyone, and other more mainstream programming languages will surely step up too.

Publications

10 25 50
publication icon
Atkey R (2013) Productive coprogramming with guarded recursion in ACM SIGPLAN Notices

publication icon
Kammar O (2013) Handlers in action

publication icon
Lindley S (2013) Hasochism

publication icon
Lindley S (2017) Do be do be do

publication icon
McBride C (2014) How to keep your neighbours in order in ACM SIGPLAN Notices

 
Description The functional programming language Haskell has an advanced type system, the design of which we have strongly influenced. As a result, it has become possible to capture strong safety and correctness properties in the type system of an industrial strength programming language. In particular, we demonstrated that it is possible to model aspects a program's awareness of the state of the environment it runs in, ensuring that the information it requests is adequate to justify the actions it performs.
Exploitation Route The main designers of Haskell are already implementing the technology we mapped out in this project.
Sectors Digital/Communication/Information Technologies (including Software)

 
Description The research outcomes from this project have helped to direct the continuing evolution of the programming language Haskell, which is developed and widely used outside the academic sector. Working with Simon Peyton Jones (Microsoft Research) and Stephanie Weirich (University of Pennsylvania), we have helped Haskell absorb features from the research languages a generation ahead of it, facilitating the adoption of new techniques whilst retaining the existing broad developer base.
First Year Of Impact 2013
Sector Digital/Communication/Information Technologies (including Software)
 
Description Visiting Researcher position at Microsoft Research Cambridge 
Organisation Microsoft Research
Country Global 
Sector Private 
PI Contribution Arising primarily from my interaction with Simon Peyton Jones concerning the evolution of the Haskell type system and my interaction with Nick Benton on type systems in general, I was invited to spend the summer of 2014 as a Visiting Researcher in the Programming Principles and Tools group of Microsoft Research, Cambridge. There, I worked with Simon on aspects of the Haskell type system and with Nick on combining linear and dependent type systems. I also began a new line of research in collaboration with Don Syme and Andy Gordon, using dependent types to model the content of real world data. The latter has led to the award of an MSR PhD scholarship to be supervised by me at Strathclyde.
Collaborator Contribution Microsoft's Programming Principles and Tools group have many interesting people to work with and manage useful paths-to-market for my research. Simon Peyton Jones and the Haskell type system design team bring my work to real programmers. Discussions with Nick Benton helped crystallize my novel treatment of linear dependent types. Andy Gordon, Don Syme and Sir Tony Hoare were of great help in developing the data-modelling project to viability.
Impact This collaboration has resulted in ongoing change to the design of Haskell's type system, as documented in the Glasgow Haskell Compiler wiki, notably here: https://ghc.haskell.org/trac/ghc/wiki/DependentHaskell. My work on linear dependent type theory is about to be published in a volume of papers dedicated to Prof Philip Wadler. My work on modelling data is listed here http://research.microsoft.com/en-US/collaboration/global/phd_projects2015.aspx has a PhD project funded by MSR.
Start Year 2014
 
Description Keynote "Is a type a lifebuoy or a lamp?" at Haskell Exchange 2016 Skills Matter event, 6 October 2016 
Form Of Engagement Activity A talk or presentation
Part Of Official Scheme? No
Geographic Reach National
Primary Audience Professional Practitioners
Results and Impact Skills Matter Haskell Exchange is a two day event for professional Haskell programmers, exchanging the latest advances and techniques. Not only was my keynote directly the outcome of research on the Haskell Types with Added Value project: several other speakers gave talks based on techniques and technologies arising in part from that work. The advanced typed programming reported in the "Hasochism" paper is very much catching on in this community of practice. Two further conference organisers expressed an intention to invite me. The talk was recorded and is available as a Skills Matter "skillscast": the number of hits is not reported.
Year(s) Of Engagement Activity 2016
URL https://skillsmatter.com/skillscasts/8893-is-a-type-a-lifebuoy-or-a-lamp
 
Description Keynote "SpaceMonads" at CodeMesh 2016, London, 3 November 2016 
Form Of Engagement Activity A talk or presentation
Part Of Official Scheme? No
Geographic Reach International
Primary Audience Professional Practitioners
Results and Impact One of the organisers of this meeting asked me on twitter if I could make it and I said yes. The talk involves live-coding in Agda, working with data structures which precisely tile within a given perimeter. It was news that this problem makes use of the kind of monadic programming familiar to Haskell programmers, and in particular, the monads on indexed types with which we did so much work in "Haskell Types with Added Value". Indeed, this talk is a small generalisation of the work on rectangular tilings which was a key example in the "Hasochism" paper arising from the project.
Year(s) Of Engagement Activity 2016
URL http://www.codemesh.io/codemesh/conor-mcbride
 
Description Keynote "What are Types for, or are they only Against?" at Yow LambdaJam, Brisbane, 8 May 2016 
Form Of Engagement Activity A talk or presentation
Part Of Official Scheme? No
Geographic Reach International
Primary Audience Professional Practitioners
Results and Impact After a couple of invitations to speak at Yow! meetings in Australia which I was unable to accept for timing reasons, in 2016, I was able to keynote at Yow! LambdaJam in Brisbane. My talk, "What areTypes for, or are they only Against?" was primarily concerned with communicating the approach and technology of Haskell programming which came about in no small part due to the "Haskell Types with Added Value" project. The audience in the room was around 100 in number, but the talk was recorded and the YouTube video, linked below, has over 3800 views. Yow! LambdaJam is attended mostly by professional functional programmers working in industry, but there is some academic presence: most participants come from Australia, but a handful from further afield. This visit also made possible a two week visit to the University of New South Wales in Sydney, where I gave two talks had some very useful interactions with functional programming researchers working in advanced type systems. although less tightly related to this project. The key impact of the talk was to persuade at least some listeners to think of types for programs, given in advance (not inferred), as a means to drive program generation (not just program criticism).
Year(s) Of Engagement Activity 2016
URL https://www.youtube.com/watch?v=3U3lV5VPmOU&list=PLIpl4GKFQR6dFB0W9IzF_gcIt1VMRnuco&index=1
 
Description Talks to sixth formers "Functional Programming (and maybe one or two other things)" at events organised by The Training Partnership (London, 24 November 2016; Warwick, 7 December 2016) 
Form Of Engagement Activity A talk or presentation
Part Of Official Scheme? No
Geographic Reach Regional
Primary Audience Schools
Results and Impact I gave the same talk at two events. It was an talk introducing concepts in functional programming, illusrtated by live coding in Haskell. The initial contact came from awareness of my "How to Keep Your Neighbours in Order" talk (arising from work on "Haskell Types with Added Value"), and indeed the content of the talk was informed by those ideas. I think at least some of the sixth formers present were interested in investigating further this mode of programming which is outside the norm for computing at schools.
Year(s) Of Engagement Activity 2016
URL http://www.thetrainingpartnership.org.uk/study-day/computer-science-in-action/