Skip to main content

Functional Programming

Downloaded: 81

Last edit: 08 September 2025

This resource forms part of the Computer Science from the Metal Up series.

Many Computer Scientists believe that Functional Programming (FP) will become the dominant paradigm for programming. AQA deserves credit for introducing it as a topic within their A-level specification. (I have met university CS lecturers who are astonished to learn that A-level students know anything at all about FP.)

Arguably, FP is the most intellectually challenging topic on the specification. Yet, at the time of writing, FP has never merited more than a single 5-point question in Paper II of the final A-Level exam. It is unsurprising, then, that most A-Level CS teachers, many of whom have little prior experience of FP, opt for a minimalist approach to teaching this topic. The result is students saying, ‘We know how to answer the exam questions, we just don’t have any understanding of what FP really is!’ And who can blame those teachers when many of the existing A-Level textbooks take a similar line? There are plenty of excellent books available on FP in general, or Haskell in particular, but these are written for professional programmers and/or 2nd year CS undergraduates, who have more practical programming experience, and stronger abstract mathematical skills, than a typical A-Level student.

This is the first published book devoted to the topic of FP, written specifically for A-Level CS students. It is based on a set of resources that I developed while teaching A-level CS at Stowe School. It is freely downloadable, and copy able, in electronic form.

I am delighted, and honoured, that Simon Peyton Jones has written a foreword to the book. Simon is well known to members of the forum as the Chair of CAS, and now also Chair of the NCCE. But perhaps not all teachers will be aware that Simon is one of the world’s foremost authorities on FP in general, and Haskell in particular. If you read nothing else from the book, please read his inspiring foreword.

Justifying the time required to teach FP

A natural reaction of any teacher would be, ‘How can I possibly justify spending the amount of time that the size of this book implies, on so small an aspect of the specification?’ Some possible answers:

  • The book is divided into Book I – Fundamentals of Functional Programming, and Book II – Delving a little Deeper. Book I is designed to cover the complete AQA specification in regard to FP.
  • For those students wanting to study CS at university, and also those planning to take another numerate subject, such as Physics, where they are likely to do some programming in an FP language as part of the degree, having had a decent introduction to FP at school will prove an advantage.
  • Learning the principles and techniques of FP can help students write better quality code, even if they are programming primarily in an imperative (procedural) or object-oriented style. And if they were to use some of these principles and techniques in their (AQA) NEA projects, and they can point clearly to these uses and explain their rationale, then there are potential marks for Technical Complexity to be gained.
  • This book reinforces several other aspects of the A-Level specification that fall outside the topic of FP. For example, Chapter 7 provides very strong reinforcement on Recursion, and Chapter 8 on the MergeSort algorithm.
  • Above all, when taught ‘for understanding’, rather than just ‘to the exam’, FP can be a hugely enjoyable topic.

Variants

Currently there are two variants of the book:

  • Functional Programming in Haskell and C#
  • Functional Programming in Haskell and VB

(why no Python version? Please see note below).

and for each of these there is both a Student Version, and a Teacher Version, the latter including multiple Teacher Notes and Model Answers to various exercises set in the book. There is also an Electronic Answer Document (Word document) in which students can write or paste their answers to the exercises.

Why teach FP in two languages?

AQA does not officially require that students know Haskell. However, all the exam questions on FP thus far have involved example code in a Haskell-like syntax. This book teaches FP through Haskell, and, in parallel, through a ‘multi-paradigm language’ with which the student is expected to be more familiar – there are currently versions for C# and VB – capable of supporting many of the key ideas in FP.

I recognise that this is an unusual approach, with both advantages and disadvantages. The rationale is two-fold. The first is that teaching FP only through Haskell, or another purpose designed FP language, runs the risk that A-Level students will understand FP primarily as new language with a very different syntax, rather than as a new paradigm, involving new ways of thinking about the problem. By learning how to do FP in a language with which they are already familiar, they are forced to confront the real changes in thinking that are required by a new paradigm. Furthermore, having learned the principles, it then becomes more obvious why a purpose-designed for FP language, such as Haskell, offers advantages. In other words, they end up with a better understanding of why Haskell is different, not just how.

The second rationale is that learning the principles also through C# or VB makes it very easy for the student to apply them in the context of their existing programming, including within their NEA project. In parallel with the book, I have developed the MetalUp.FunctionalLibrary. The library is free, and easy to install as a NuGet package. It may be used in an NEA project, like any existing library or framework, provided it is clearly acknowledged as an external resource, and that the student claims only examples of applying the capabilities of library within their own code, not the library code itself, as evidence of technical complexity.

Errors

Despite my best efforts, and feedback from a few teachers before publication, it would be astonishing if this first version of the book was error-free. Please report any errors, no matter how large or small, to me by email, and I will undertake to correct them and issue a new version, via this forum, very promptly. Please also feel free to send feedback, including any aspects of the book that you feel could be improved.

Why is there no Python version?

Python is a multi-paradigm programming language capable of supporting FP, just as C# and VB can. Elsewhere on this forum, I have made no secret of my dislike for Python as a teaching language (because of it being dynamically typed), but the lack of a Python version of this book is not for that reason. My primary teaching language is C#, and it is a straightforward matter for me to translate C# code into VB. Moreover, the free library that I wrote to accompany the book will work with any .NET language, but not other platforms. Writing a Python version of the book will take rather more effort. I might get around to it, but I have other projects pending.

If any teacher is interested in translating the book to Python, please email me, but be warned that there is quite a lot of work involved. I am quite happy to share the credit, and the royalties, but please remember that div 0 n = 0, and not just in Haskell ;-)