Skip to content

About

Learn functional programming by building a linear-time regular expression engine in Idris 2 — test-first, step by step.

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Repository files navigation

Let's Start Functional

Learn functional programming by building a linear-time regular expression engine in Idris 2, test-first.

This repository contains:

  • regex/: the engine itself, written in Idris 2 with TDD. Matching runs in a single left-to-right pass over the input, so there is no backtracking to blow up.
  • content/: the tutorial book (English / 日本語), built with Vite+ and Ox Content.

Why?

Functional programming has a reputation for being hard to start. This tutorial takes the opposite route: build one small, real, useful thing (a regex engine) and let each language feature earn its keep, one chapter at a time.

  • No prior functional programming experience required.
  • Every feature starts with a failing test.
  • The commit history is the tutorial: each step is a small red/green commit you can replay.

The book

Read it on the site (English / 日本語) or right here on GitHub, in order:

# English 日本語
01 Why Functional? Why Idris? なぜ関数型?なぜIdris?
02 What Is a Regex Engine? 正規表現エンジンとは
03 Setting Up 環境構築
04 An Idris Crash Course Idris速習
05 TDD and a Tiny Test Harness TDDと小さなテストハーネス
06 A Regex Is Data 正規表現はデータである
07 nullable: Matching Nothing nullable:空文字列とのマッチ
08 The Derivative 微分
09 matches: The Whole Engine matches:エンジン完成
10 Smart Constructors スマートコンストラクタ
11 Character Classes 文字クラス
12 Sugar Is Just Functions 糖衣構文はただの関数
13 Parser Combinators パーサコンビネータ
14 Parsing Pattern Syntax パターン構文をパースする
15 A Public API 公開API
16 Interfaces and Two Monoids インターフェースと2つのモノイド
17 Printing Patterns Back パターンを印字し直す
18 Tests Become Theorems テストが定理になる
19 The Race: Linear vs Backtracking 対決:線形時間vsバックトラック
20 Capstone: A Lexer 総仕上げ:レキサ
21 What's Next この先へ

Getting started

Read the book, or jump straight into the code:

cd regex
make test    # build the library and run the whole suite
make bench   # race the derivative engine against a backtracker

To run the book locally:

pnpm install
pnpm dev       # English
pnpm dev:ja    # 日本語

Deploying

The book deploys to Void from GitHub Actions using OIDC, so there is no long-lived secret to store. One-time setup:

  1. pnpm exec void init locally (log in and link/create the project).
  2. Set the repository variable VOID_PROJECT to the project slug. The Deploy workflow switches on automatically from the next push to main.

License

MIT

About

Learn functional programming by building a linear-time regular expression engine in Idris 2 — test-first, step by step.

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages