15-150: Functional Programming, Summer 2025 (original) (raw)
Overview
The purpose of this course is to introduce the theory and practice of functional programming (FP). The characteristic feature of FP is the emphasis on computation as evaluation. The traditional distinction between program and data characteristic of_imperative programming (IP)_ is replaced by an emphasis on classifying expressions by types that specify their applicative behavior. Types include familiar (fixed and arbitrary precision) numeric types, tuples and records (structs), classified values (objects), inductive types such as trees, functions with specified inputs and outputs, and commands such as input and output. Well-typed expressions are evaluated to produce values, in a manner that is guaranteed to be type-safe. Because functional programs do not cause side-effects we can take advantage of simple mathematical principles in reasoning about applicative behavior and analyzing the runtime properties of programs.
The advantages of FP are significant:
- Verification: There is a close correspondence between the mathematical reasoning that justifies the correctness of a program and the program itself. Principles of proof by mathematical induction go hand-in-hand with the programming technique of recursion.
- Parallelism: Since expressions have no side-effects, it is natural to use parallel evaluation: the values of independent subexpressions may be determined simultaneously, without fear of interference or conflict, and the final result is not affected by evaluation order. This gives rise to the central concepts of the work (sequential) and span (idealized parallel) complexity of a program, and allows programs to exploit available parallelism without fear of disrupting their correctness.
- Abstraction: FP stresses data-centric computation, with operations that act on compound data structures as whole, rather than via item-by-item processing. More generally, FP emphasizes the isolation of abstract types that clearly separate implementation from interface. Types are used to express and enforce abstraction boundaries, greatly enhancing maintainability of programs, and facilitating team development.
Moreover, FP generalizes IP by treating commands as forms of data that may be executed for their effects.
Learning Outcomes
Upon completion of this course, students will have acquired a mastery of basic functional programming techniques, including the design of programs using types, the development of programs using mathematical techniques for verification and analysis, the use of abstract types and modules to structure code, and the exploitation of parallelism in applications.
In particular, a student taking this course will learn to:
- Write well-typed functional programs using the language ML
- Develop specifications and prove program correctness using rigorous techniques
- Apply equational, evaluational, and compositional reasoning techniques, and use mathematical and structural induction in proofs
- Analyze sequential and parallel running time of programs using the concepts of work and span
- Develop cost graphs and recurrences from programs, and use them to derive asymptotic bounds on work and span
- Use abstract types and modules to structure code with clear and well-designed interfaces
- Identify opportunities for parallelism in code and exploit parallelism by choosing appropriate data structures and function designs
Prerequisites:
Prerequisite courses are (15-151 or 21-127 or 21-128) and (15-112 or 15-122).
Students should also have some basic mathematical background, such as the ability to do a proof by mathematical induction, in order to reason about program correctness. In addition, it will be very useful for a student to have developed abstraction skills and to have familarity with the core mathematical structures of Computer Science, such as sets, relations, graphs, and trees.
Successful completion of this course is necessary and sufficient for entry into 15-210 Data Structures and Algorithms, which will build on the functional model of computation to develop a modern account of parallel algorithms for a wide variety of abstract types.
Note to Students
Take care of yourself. Do your best to maintain a healthy lifestyle this semester by eating well, exercising, avoiding drugs and alcohol, getting enough sleep and taking some time to relax. This will help you achieve your goals and cope with stress.
All of us benefit from support during times of struggle. You are not alone. There are many helpful resources available on campus and an important part of the college experience is learning how to ask for help. Asking for support sooner rather than later is often helpful.
If you or anyone you know experiences any academic stress, difficult life events, or feelings like anxiety or depression, we strongly encourage you to seek support. Counseling and Psychological Services (CaPS) is here to help: call 412-268-2922 and visit their website athttp://www.cmu.edu/counseling/. Consider reaching out to a friend, faculty or family member you trust for help getting connected to the support that can help.
The university is technically required by federal law to not discriminate on the basis of race, color, national origin, sex, handicap or disability, age, sexual orientation, gender identity, religion, creed, ancestry, belief, veteran status, or genetic information. Therefore, the university is obligated to encourage anyone who experiences or observes unfair or hostile treatment on the basis of identity to speak out for justice and support, within the moment of the incident or after the incident has passed. Anyone can share these experiences using the following resources:
- Center for Student Diversity and Inclusion:csdi@andrew.cmu.edu, (412) 268-2150
- Report-It online anonymous reporting platform:<reportit.net> username: tartans password: plaid
- Smashing a window and leaving a note.
If you or someone you know is feeling suicidal or in danger of self-harm, call someone immediately, day or night:
CaPS: 412-268-2922
Resolve Crisis Network: 888-796-8226
Suicide and Crisis Lifeline: 988
If the situation is life threatening, call the police:
On campus: CMU Police: 412-268-2323
Off campus: 911
Past Instances
- Spring 2025, taught by Michael Erdmann and Dilsun Kaynar
- Fall 2024, taught by Dilsun Kaynar and Stephanie Balzer
- Summer 2024, taught by Harrison Grodin
- Spring 2024, taught by Michael Erdmann and Dilsun Kaynar
- Fall 2023, taught by Steve Brookes
- Summer 2023, taught by Brandon Wu
- Spring 2023, taught by Michael Erdmann and Karl Crary
- Fall 2022, taught by Steve Brookes
- Summer 2022, taught by David Kahn
- Spring 2022, taught by Michael Erdmann and Karl Crary
- Fall 2021, taught by Steve Brookes
- Summer 2021, taught by Jacob Neumann
- Spring 2021, taught by Michael Erdmann and Karl Crary
- Fall 2020, taught by Steve Brookes
- Summer 2020, taught by Jacob Neumann and Dilsun Kaynar
- Spring 2020, taught by Michael Erdmann and Frank Pfenning
- Fall 2019, taught by Steve Brookes
- Summer 2019, taught by Klaas Pruiksma
- Spring 2019, taught by Michael Erdmann and Karl Crary
- Fall 2018, taught by Steve Brookes
- Summer 2018, taught by Stefan Muller
- Spring 2018, taught by Michael Erdmann and Dilsun Kaynar
- Fall 2017, taught by Steve Brookes and Dilsun Kaynar
- Summer 2017, taught by Dilsun Kaynar
- Spring 2017, taught by Michael Erdmann and Dilsun Kaynar
- Fall 2016, taught by Steve Brookes and Dilsun Kaynar
- Summer 2016, taught by Rose Bohrer
- Spring 2016, taught by Michael Erdmann
- Fall 2015, taught by Steve Brookes
- Spring 2015, taught by Michael Erdmann
- Fall 2014, taught by Steve Brookes
- Summer 2014, taught by Carlo Angiuli
- Spring 2014, taught by Michael Erdmann
- Fall 2013, taught by Steve Brookes
- Summer 2013, taught by Iliano Cervesato
- Spring 2013, taught by Michael Erdmann
- Fall 2012, taught by Steve Brookes and Jeannette Wing
- Summer 2012, taught by Ian Voysey
- Fall 2011 and Spring 2012, taught by Dan Licata
- Spring 2011, created and taught by Robert Harper and Dan Licata