Learn · NPTEL

Course10610600273 lectures

Functional Programming with OCaml

Prof. K C Sivaramakrishnan · IIT Madras

Start with lecture 1 At NPTEL

About

This course introduces the principles of functional programming using OCaml, with a strong emphasis on building reliable and secure software systems. It covers core concepts such as higher-order functions, type systems, and modular design, along with advanced topics like concurrency and memory safety. Through hands-on programming assignments and projects, learners will gain practical experience in writing robust systems software using modern functional programming techniques.

The interactive course book is available at: https://fplaunchpad.org/ocaml_nptel/

Intended audience: • Undergraduate and postgraduate students in Computer Science and related disciplines. • Systems engineers, software developers, and researchers. • Professionals interested in secure and reliable software development. • Any interested learners.

Prerequisites: C Programming, Data structures and Algorithms

Lectures

Week 1

  1. Course introduction: what you'll learn, how it's run YouTube
  2. Why functional programming? YouTube
  3. A tour of OCaml: values, types, and the toplevel YouTube
  4. Your first OCaml program: hello, world (and beyond) YouTube
  5. Tutorial: temperature conversions and small expressions YouTube

Week 2

  1. Literals: integers, floats, booleans, strings YouTube
  2. `let` bindings and shadowing YouTube
  3. Static vs dynamic semantics, and type inference YouTube
  4. Operators, precedence, and common pitfalls YouTube
  5. `if`/`then`/`else` as an expression YouTube
  6. Tutorial: small expressions, end to end YouTube

Week 3

  1. Functions as values, and anonymous functions YouTube
  2. Recursion YouTube
  3. Currying and partial application YouTube
  4. Tail recursion and accumulators YouTube
  5. Local functions and mutual recursion YouTube
  6. Tutorial: Fibonacci, GCD, power, digits YouTube

Week 4

  1. Tuples YouTube
  2. Records YouTube
  3. Variants (sum types) YouTube
  4. Recursive types: lists, trees, expressions YouTube
  5. Tutorial: a tiny AST for OCaml YouTube
  6. Tutorial: a tiny file system YouTube

Week 5

  1. Basic patterns: literals, variables, wildcards YouTube
  2. Pattern matching on lists and trees YouTube
  3. Nested patterns and or-patterns YouTube
  4. Guards: when-clauses on patterns YouTube
  5. Exhaustiveness checking YouTube
  6. Tutorial: an interpreter for the OCaml AST YouTube

Week 6

  1. Functions as values, revisited YouTube
  2. map: transform every element YouTube
  3. filter: keep what passes the predicate YouTube
  4. fold: reduce a list to a single value YouTube
  5. Function composition and pipelines YouTube
  6. Tutorial: fold across data structures YouTube

Week 7

  1. Mutable references YouTube
  2. Mutable records and arrays YouTube
  3. Exceptions YouTube
  4. Streams and Laziness YouTube
  5. Memoization YouTube
  6. Module basics YouTube
  7. Module signatures YouTube
  8. Functors YouTube
  9. Tutorial: A Queue functor YouTube

Week 8

  1. The option monad and `let*` YouTube
  2. Monad laws, the list monad, and the result monad YouTube
  3. The state monad and parameterised state YouTube
  4. GADTs: variants with type-level information YouTube
  5. GADTs: use cases beyond toy interpreters YouTube
  6. GADTs: hlists and witnesses YouTube
  7. Tutorial: a tiny well-typed evaluator YouTube

Week 9

  1. Why test a type-safe program? YouTube
  2. Specifications and invariants YouTube
  3. Designing test cases: black-box and glass-box YouTube
  4. Unit testing YouTube
  5. Property-based testing with QCheck YouTube
  6. Model-based testing of stateful data structures YouTube
  7. Tutorial: testing the expr evaluator with OUnit2 and QCheck YouTube

Week 10

  1. What memory safety is, and why it is a security story YouTube
  2. Memory safety by construction YouTube
  3. Data races are undefined behaviour YouTube
  4. Where OCaml itself has UB YouTube
  5. Tutorial: walking Heartbleed end to end YouTube

Week 11

  1. Locality: safe stack allocation YouTube
  2. Uniquenss: the only reference YouTube
  3. Linearity: use at most once YouTube
  4. Contention: Synchronisation at compile time YouTube
  5. Portability: data race freedom across domains YouTube
  6. Tutorial: a resource-management API YouTube

Week 12

  1. Why do we need an OS? YouTube
  2. MirageOS Unikernel Background YouTube
  3. MirageOS Basics YouTube
  4. Suresh the Stationmaster: a worked unikernel example YouTube

Syllabus and materials

At NPTEL, as the course publishes them.

Credits and licence

Institution
IIT Madras
Department
Computer Science and Engineering
Teacher
Prof. K C Sivaramakrishnan
Level
Undergraduate
Language
English
Subjects
Computer science, Engineering
Source
NPTEL
Licence
CC BY-NC-SA, as NPTEL states it. Non-commercial use only. NPTEL's terms
Attribution
NPTEL states: "Distributed under Creative Commons Attribution-ShareAlike / CC BY - NC - SA", beside a BY-NC-SA badge.
Who can watch
NPTEL gives no rating. Invisible Network shows it to Tweens profiles and older, judged from what the source says about it. How courses are placed