idris2-tutorial
idris2-tutorial copied to clipboard
Functional Programming in Idris 2
The goal of this project is quickly explained: To become a more or less comprehensive guide to the Idris programming language, with a lot of introductory material targeted at newcomers to functional programming.
The content will be organized in several parts, with the part
about the core language features being the main guide to
functional programming in Idris. Every part consists of several
chapters, each trying to cover in depth a certain aspect
of the Idris programming language and its core libraries. Most
chapters come with (sometimes lots of) exercises, with
solutions available in directory src/Solutions
.
Right now, even the part about core language features is not yet finished, but is being actively developed and tried on several of my own students, some of which are completely new to functional programming.
Table of Contents
Part 1: Core Language Features
This part tries to give a solid introduction to the Idris programming language. If you are new to functional programming, make sure to follow these chapters in order and solve all the exercises.
If you already used other pure functional programming languages like Haskell, you might go through the introductory material (Functions Part 1, Algebraic Data Types, and Interfaces) pretty quickly, as most of this stuff will already be familiar to you.
-
Introduction
- About the Idris Programming Language
- Using the REPL
- A First Idris Program
- The Shape of an Idris Definition
- Where to get Help
-
Functions Part 1
- Functions with more that one Argument
- Function Composition
- Higher-order Functions
- Currying
- Anonymous Functions
- Operators
-
Algebraic Data Types
- Enumerations
- Sum Types
- Records
- Generic Data Types
- Alternative Syntax for Data Definitions
-
Interfaces
- Interface Basics
- More about Interfaces
- Interfaces in the Prelude
-
Functions Part 2
- Let Bindings and Local Definitions
- The Truth about Function Arguments
- Programming with Holes
-
Dependent Types
- Length-Indexed Lists
- Fin: Safe Indexing into Vectors
- Compile-Time Computations
-
IO: Programming with Side Effects
- Pure Side Effects?
- Do Blocks, Desugared
- Working with Files
- How IO is Implemented
-
Functor and Friends
- Functor
- Applicative
- Monad
- Background and further Reading
-
Recursion and Folds
- Recursion
- A few Notes on Totality Checking
- Interface Foldable
-
Effectful Traversals
- Reading CSV Tables
- Programming with State
- The Power of Composition
-
Sigma Types
- Dependent Pairs
- Use Case: Nucleic Acids
- Use Case: CSV Files with a Schema
-
Propositional Equality
- Equality as a Type
- Programs as Proofs
- Into the Void
- Rewrite Rules
-
Predicates and Proof Search
- Preconditions
- Contracts between Values
- Use Case: Flexible Error Handling
- The Truth about Interfaces
-
Primitives
- How Primitives are Implemented
- Working with Strings
- Integers
- Refined Primitives
Part 2: Appendices
The appendices can be used as references for the topics at hand. I plan to eventually have a concise reference on Idris syntax, typical error messages, the module system, interactive editing and possibly others.
- Getting Started with pack and Idris2
- Interactive Editing in Neovim
- Structuring Idris Projects
Prerequisites
At the moment, this project is being actively developed and evolved against the main branch of the Idris 2 repository. It is being tested nightly on GitHub and built against the latest version of pack's package collection.
In order to follow along with this tutorial, it is strongly suggested to install Idris via the pack package manager as described here.