Curry On!
AI-assisted summary of Edwin Brady - Idris 2 - Type-driven Development of Idris — original source. Check the original for full context.
Source published:
Key ideas
- Edwin Brady announced Idris 2, a complete rewrite of the Idris compiler implemented in Idris itself to address severe type-checker latency encountered when tracking external state. (0:04)
- Idris 2 integrates Conor McBride and Bob Atkey's Quantitative Type Theory (QTT), tagging all variable bindings with runtime usage quantities of 0 (erased), 1 (linear), or unrestricted (ω). (2:55)
- The compiler targets Chez Scheme rather than emitting C code as Idris 1 did, capitalizing on decades of runtime optimization to deliver faster execution out of the box. (24:45)
- Linear quantity constraints substantially narrow the search space for automated type-directed program synthesis, preventing search routines from generating non-terminating loops. (16:59)
Detailed notes
## Background This talk was delivered by Edwin Brady, published on YouTube by the Curry On! channel on July 18, 2019. The presentation provides a show-and-tell demonstration of Idris 2, though the original upload includes no additional video description or show notes.
## TL;DR Edwin Brady presents Idris 2, a complete re-implementation of the Idris language written in itself to overcome severe type-checker performance bottlenecks. The core architectural leap is the integration of Quantitative Type Theory (QTT), which assigns compile-time usage quantities (0 for erased, 1 for linear, and unrestricted) to variables. Brady demonstrates how these quantities supercharge interactive type-driven editing and automated program synthesis, compile efficiently via Chez Scheme, and enable precise state tracking. Finally, he showcases how combining linear and dependent types allows developers to cleanly model and verify communicating systems via session types.
## Atmosphere & style The presentation is warm, humorous, and refreshingly down-to-earth, defined by Brady's self-deprecating wit about his PowerPoint skills, keyboard blunders on Linux, and personal habits. It feels like an intimate, excited show-and-tell rather than an austere academic lecture, with Brady genuinely reveling in the speed of the new compiler. The live-coding demonstrations create an engaging, conversational dynamic where compiler errors and interactive hole inspections are treated as helpful dialogues rather than hostile reprimands.
## Bulletin - [00:04](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=4s) Edwin Brady announced Idris 2, a complete rewrite of the Idris compiler implemented in Idris itself to address severe type-checker latency encountered when tracking external state. - [02:55](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=175s) Idris 2 integrates Conor McBride and Bob Atkey's Quantitative Type Theory (QTT), tagging all variable bindings with runtime usage quantities of 0 (erased), 1 (linear), or unrestricted (ω). - [24:45](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=1485s) The compiler targets Chez Scheme rather than emitting C code as Idris 1 did, capitalizing on decades of runtime optimization to deliver faster execution out of the box. - [16:59](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=1019s) Linear quantity constraints substantially narrow the search space for automated type-directed program synthesis, preventing search routines from generating non-terminating loops.
## Key takeaways - [00:04](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=4s) Type-checker performance bottlenecks in Idris 1 motivated a complete ground-up rewrite using Idris as the implementation language. - [02:55](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=175s) Type-driven development reframes the compiler from an adversary into a collaborative conversational partner through hole-driven interactive editing. - [02:55](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=175s) Quantitative Type Theory provides a formal foundation that cleanly distinguishes compile-time reasoning from runtime execution via quantities 0, 1, and ω. - [05:49](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=349s) Variables marked with quantity 0 are guaranteed by the type system to be completely erased from compiled runtime code. - [10:07](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=607s) Automated expression search and Djinn-style proof synthesis can eliminate structural boilerplate such as tuple unpacking and projection functions. - [13:46](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=826s) Linear variables (quantity 1) must be consumed exactly once across an expression, forbidding both duplication and accidental dropping. - [16:59](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=1019s) Pattern matching or case-splitting on erased (0-quantity) runtime variables is strictly prohibited and caught at compile time. - [16:59](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=1019s) Imposing linear constraints on function inputs inadvertently accelerates type-directed program synthesis by eliminating unviable code generation paths. - [20:34](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=1234s) In Idris 2, variables needed at runtime must be explicitly quantified in the type signature rather than inferred implicitly. - [24:45](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=1485s) Switching the Idris 2 code generation target to Chez Scheme yields significant performance improvements over Idris 1's C backend. - [26:12](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=1572s) Resource tracking via linear types enables safe modeling of stateful external protocols where invalid transitions and resource leaks become compile-time errors. - [31:51](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=1911s) Session types for concurrent client-server protocols can be directly expressed using standard language primitives when dependent types are paired with linearity. - [39:27](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=2367s) Custom dependent pair structures can assign different quantitative multiplicities to each contained component.
## Detailed walkthrough ### [00:04](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=4s) Re-engineering Idris in Itself
Edwin Brady opens with a self-deprecating joke about having worked hard on his PowerPoint skills, introducing the talk as a show-and-tell session. For the preceding few months, he had been hiding away in his office cupboard building a brand-new implementation of Idris—Idris 2. He polls the audience on whether they have played with dependently typed programming languages before, noting with satisfaction that hands are going up across the room and that the proportion of practitioners seems to grow each time he asks. Rather than questioning their exact level of experience, he assumes basic familiarity and focuses on how Idris 2 handles those fundamentals, what new capabilities it introduces, and why he undertook the rewrite.
The primary motivation stemmed from his work a couple of years earlier on using types to track state changes in the outside world, particularly in concurrent and network protocol programming. He wanted the type system to guarantee correctness, but the Idris type checker had become frustratingly slow. Facing the realization that this performance bottleneck was his own responsibility, he decided to re-engineer the system from the ground up, implementing it in Idris itself to see where dependent types could aid the compiler construction. While setting aside the deep implementation details of Idris 2 for a future talk, he highlights that the immediate payoff is blazing speed: he admits he has reached the point of re-checking files simply for the sheer joy of watching them pass in reasonable time.
Full-sentence quote: > “I'm at a point at the minute where I've just made it a kind of a big a big improvement in the speed, I'm retype checking things just for the joy of seeing things type check in reasonable time to marvelous, I don't get out much you know so.” — Edwin Brady
- Idris 2 is a complete rewrite of Idris implemented in Idris itself. - A core practical motivation was resolving severe type-checker latency encountered when tracking external state and verifying network and concurrency protocols.
[02:55](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=175s) Interactive Editing and Quantitative Type Theory
Brady emphasizes that type-driven development is fundamentally about interactive editing—maintaining an active dialogue between the developer and the machine. In languages with advanced type systems, programmers too often view the compiler as an adversary, lamenting on IRC or mailing lists that the compiler hates them or is shouting at them. Brady insists that the tool should feel like a partner in conversation, and Idris 2 is designed to double down on this collaborative editing workflow.
The defining theoretical foundation of Idris 2 is Quantitative Type Theory (QTT), developed over recent years by Conor McBride and Bob Atkey. In QTT, every variable binding is annotated with a quantity describing how many times it may be used at runtime. Brady explains that the theory centers on three interesting quantities:
| Quantity | Meaning at Runtime | Guarantee / Behavior | |:--- |:--- |:--- | | `0` | Erased | Available for compile-time reasoning and proofs, but guaranteed by the type system not to exist at runtime. | | `1` | Linear | Must be used exactly once at runtime; cannot be duplicated or dropped. | | `ω` (Many) | Unrestricted | Traditional unrestricted usage; values can be referenced zero, one, or multiple times. |
Brady notes that combining linearity (quantity `1`) with dependent types opens the door to powerful resource-aware abstractions such as session types (pioneered by Kohei Honda and others) for verifying communicating concurrent systems. Having kept the repository private to avoid disrupting contributors during major internal architectural refactorings, he announces that the project had been made public on GitHub just a week earlier and invites the community to submit issues and contribute.
Full-sentence quote: > “I don't want you to think Idris is shouting at you, Idris is trying to help you, it's trying to be in a conversation with you, and I think we need to, one thing we need to do is work quite a lot harder at making that the way people interact with the system.” — Edwin Brady
[05:49](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=349s) Vectors, Quantities, and Interactive Synthesis
Moving to code, Brady acknowledges the running trope in dependent type presentations: by law, he has to demonstrate length-indexed vectors (`Vect`), even if experienced listeners "die inside" from seeing it again. However, the vector example in Idris 2 illustrates crucial new semantics regarding quantities. In an append signature:
$$\text{append}: \text{Vect } m\ a \to \text{Vect } n\ a \to \text{Vect } (m + n)\ a$$
the implicit arguments ($m$, $n$, and $a$) exist solely to specify the type. Brady shows how the interactive workflow proceeds: the developer writes the type, creates a skeleton definition, and interacts with the compiler through a "hole."
```mermaid flowchart LR accTitle: Type-Driven Interactive Editing Cycle accDescr: The cycle of declaring a type, generating a candidate definition with holes, inspecting holes, and refining via case splits and proof search. A["Declare Type Signature"] --> B["Add Candidate Definition"] B --> C["Inspect Hole & Context"] C --> D["Case Split on Variable"] D --> E["Search / Refine Solution"] E -.->|"Repeat if necessary"| C ```
When inspecting the hole of the candidate definition, the environment explicitly displays a quantity of `0` beside `m`, `a`, and `n`. This gives the programmer an absolute compile-time guarantee that these variables are completely erased from the runtime output. Brady then demonstrates interactive construction: case-splitting on the first vector generates the `Nil` and `::` branches. Pressing `Ctrl+Alt+S` invokes expression search, which inspects the local context and automatically synthesizes the matching implementations. Noting that human development often follows repetitive patterns—brute-force case splitting followed by search—he poses the question of whether this procedural process itself can be abstracted away so the machine executes these recursive steps automatically.
Full-sentence quotes: > “These say you can talk about $m$, $a$, and $n$ as much as you like at compile time, but there will be zero of them at runtime, guaranteed these are erased, guaranteed that the type system ensures that they won't appear in our program.” — Edwin Brady > > “There's a process we're following, and somehow the act of programming is not just about the end result, it's sort of what we do to get there, and we kind of know that when we write programs and we do we have programs that are repetitive, so we have weekly repeated patterns in the code itself, we abstract it away, so wouldn't it be nice if we could abstract away in the act of programming?” — Edwin Brady
- Type-driven development follows a strict loop: *Type, Define, Refine*. - Quantities are directly visible during interactive inspection inside the hole environment. - The `Ctrl+Alt+S` interactive search command uses the types of values in scope to automatically complete terms.
[10:07](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=607s) Type-Driven Program Synthesis and Proof Search
Continuing his demonstration of interactive editing, Edwin Brady illustrates how code synthesis operates like a classic illusion: “Literally all that's happened, this is just a magic trick, but the cool thing is just because we've given that little extra bit of information in the type, we can do that magic trick.” Rather than having the system's "split and search" functionality entirely hard-coded, his broader ambition for Idris is to empower developers to write their own custom abstractions over program fragments. Brady addresses a common anxiety among programmers regarding automated synthesis, quipping: “Sometimes I see people comment that, ‘Oh no, you're taking my job away as a programmer.’ Well no, you still have to know what you're doing, you still have to know the programs you want to write, and it's still good to have a feel for when it's going to work.”
Much of what search excels at involves structural "plumbing"—such as unpacking and repackaging tuples or pairs. To showcase this, Brady brings up examples borrowed directly from the documentation of Djinn, the well-known Haskell tool that uses Roy Dyckhoff's proof search algorithm to extract programs from intuitionistic propositional types. While navigating his editor, he fumbles briefly with keybindings and explains the mishap with a self-deprecating laugh: having recently switched his operating system from macOS to Linux because he heard that “next year is the era of Linux on the desktop,” he is still adjusting to the new keyboard layout.
Moving beyond pairs, Brady demonstrates synthesis on dependent data structures, specifically a heterogeneous list where the type of each element is tracked inside the type of the list itself. He argues that once a programmer defines a type-level predicate specifying that an element of a particular type exists at a given location, the compiler already has all the logical information it needs to extract it: “I sort of feel like if we go to the trouble of expressing a predicate that says that a value at a particular location is a particular type, surely we've done enough work to write the program that pulls that value out of the list. I shouldn't have to write that program again.” He jokes about formulating complex examples in a pub the previous day while distracted by a cricket match, noting that the search repeatedly failed until he finally refined the types properly.
- The interactive command `Ctrl+G` triggers the automated proof search to fill holes in the editor. - Dyckhoff’s LJT proof search algorithm (implemented in Haskell’s Djinn) provides the theoretical foundation for synthesising structural boilerplate from types. - Expressing invariants as predicates in types allows the machine to derive projection functions automatically instead of forcing the user to implement them by hand.
---
[13:46](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=826s) Quantitative Type Theory and Linear Types in Idris 2
Brady introduces the core architectural evolution of Idris 2: the integration of Quantitative Type Theory (QTT). He credits this theoretical leap to Conor McBride and Bob Atkey, admitting with humor, “I'm so glad they did this because I've wanted this for ages, but I don't have the skills to figure out the type theory details myself.” While sharing an intuitive overlap with Linear Haskell, QTT in Idris 2 assigns a quantitative usage annotation to variables in function types. A variable annotated with quantity `1` (`(1 x: A)`) means that if the resulting function application $f(x)$ is evaluated exactly once, the argument $x$ must also be consumed exactly once.
To demonstrate how the type checker enforces linear constraints, Brady tries to construct a pair function (`pair: (1 x: A) -> (A, A)`) where a single input $x$ is replicated. When unrestricted, synthesizing `pair x = (x, x)` succeeds trivially because there is only one available value of type $A$. However, the moment $x$ is annotated with quantity `1`, synthesis fails. Inspecting the proof state inside the hole (`pair_rhs`), Brady shows that placing $x$ into the first position of the pair consumes the available usage: checking the remaining hole reveals that zero uses of $x$ remain. Trying to compile a definition with two references produces a compiler error: “There are two uses of linear name `x`.” Brady jokes about the compiler outputting a cheery greeting alongside the error message: “It just occurred to me this morning when I was working through this, I put this jaunty little message ‘enjoying yourself?’ and it's just told you that your program's wrong, and I'm thinking that might start to annoy me.”
He also clarifies that linearity is a whole-expression constraint rather than a syntactic left-to-right evaluation order: placing $x$ in the second position of the tuple still expends the single allowed usage, leaving none for the first position.
```mermaid flowchart TD accTitle: Quantitative Usage in Pair Construction accDescr: Diagram showing how a linear resource of quantity 1 is depleted upon first use, preventing duplicate consumption.
subgraph Input ["Linear Input"] X["Linear variable: (1 x: A)"] end
subgraph Eval ["Tuple Construction: (x,?)"] FirstUse["First slot consumes x (usage = 1)"] RemainingHole["Second slot: Remaining usage of x = 0"] end
subgraph Result ["Type Checker Verdict"] Valid["Single use: Valid"] Error["Attempting (x, x): 'Two uses of linear name x'"] end
X --> FirstUse FirstUse --> RemainingHole RemainingHole --> Error ```
---
[16:59](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=1019s) Erasure (0-Quantity) and Type-Directed Synthesis
Brady explores the other extreme of QTT: the quantity `0`, which designates arguments that are erased at runtime and exist strictly for compile-time reasoning and proofs. A parameter annotated with `0` cannot be inspected or pattern-matched upon at runtime. Brady sets up a trivial function attempting to invert a boolean with an erased quantity annotation `(0 b: Bool) -> Bool`. While the editor mistakenly allows case-splitting on `b` in the interactive buffer, the Idris 2 compiler immediately rejects it upon reload with an explicit error: “Attempt to match on erased argument.” Erased quantities solve the long-standing problem in dependent type systems of ensuring that compile-time proofs do not leak into runtime overhead.
Brady explains an accidental discovery he made while implementing QTT: while linear types are traditionally cited for resource tracking (preventing aliasing in stateful protocols) or memory efficiency (reusing buffers in place), quantities also supercharge type-directed program synthesis. By restricting a list parameter to quantity `1` in a standard `map` function signature, the search space collapses: “Kind of by accident, I discovered that the linearity gives more information to the type-directed synthesis. Here I've got a map function where I'm consuming the list exactly once, so that turns out to be enough to find the definition, because there's only one way of consuming that list exactly once in order to build this program.”
An audience member asks an inaudible question about whether this search capability generalizes, to which Brady responds with genuine enthusiasm: “That's a fantastic question. I'll show you how it doesn't work! It's a fantastic question, but I'd better move on.”
---
[18:57](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=1137s) Live Demo: Matrix Transposition and Runtime Quantities
To illustrate how quantities enforce correctness and expose hidden dependencies in realistic code, Brady turns to vector transposition: transposing an $m \times n$ matrix into an $n \times m$ matrix. Implementing matrix transpose serves as an ideal benchmark for type-driven development because the dimensions are embedded directly within the vector types.
Brady begins by generating a skeleton definition for `transpose` and pattern matching on the matrix argument:
1. Matching against the empty matrix case (`Nil`) leaves a hole, which he renames to `empties`. 2. Hitting `Ctrl-Alt-L` generates the type required to fill `empties`, which needs to produce $n$ copies of an empty vector to serve as the initial accumulator. 3. However, an immediate obstacle arises: inspecting the proof context reveals that the dimension variable $n$ is marked as having quantity `0` (erased at runtime). 4. Because $n$ is erased, the runtime program cannot evaluate $n$ to know how many empty vectors to construct: “If I look at the type, I see that I'm not allowed to have $n$ at runtime, so it is a zero quantity at runtime. So there's no way I'm going to be able to produce $n$ copies of the empty vector, because $n$ is not available to me at runtime.”
This fundamental tension between erased type-level indices and runtime execution requirements highlights the strict, disciplined guarantees Quantitative Type Theory introduces into Idris 2.
[20:34](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=1234s) Runtime Quantities and Vector Transposition
Edwin Brady highlights a notable difference between Idris 1 and Idris 2 regarding compile-time versus runtime availability of variables. In Idris 2, if a variable needs to exist at runtime, it must be explicitly written down in the type signature with the correct quantity; the general rule of thumb is:
> “Basically if you write it down it's in your program, you don't write it down it's not.”
When lifting out the helper function `empties` for matrix transposition, providing the dimension `m` explicitly as a runtime quantity informs the system that `m` can be used to generate values dynamically at runtime, allowing the interactive tool to successfully generate the code.
```mermaid flowchart TD accTitle: Matrix Transposition Helper Flow accDescr: Step-by-step logic showing how an inductive recursive call transposes vectors and consumes them linearly. subgraph Input ["Input Matrix"] M1["Head Vector: x"] M2["Tail Matrix: xs"] end subgraph Recurse ["Inductive Step"] Rec["Recursive Call: transpose xs"] end subgraph Combine ["Linear Assembly"] Helper["transpose_helper: zip x into transposed rows"] LinearCheck{"Is vector used exactly once?"} end subgraph Output ["Result"] Res["Fully Transposed Matrix"] end
M2 --> Rec M1 --> Helper Rec --> Helper Helper --> LinearCheck LinearCheck -->|"Quantity 1 enforced"| Res ```
Moving to the inductive step of `transpose`, the goal is to recursively transpose the remaining rows (`xs`) and then rotate or prepend the elements of the first row (`x`) across the transposed columns. When Brady initially invokes the inductive hypothesis and asks the type-directed program search to generate a helper function automatically, the search creates an implementation that loops endlessly:
> “I haven't put a termination checker in the type-directed program search yet so I like to show this just because like you can't just blindly press buttons and hope that the program comes out is going to be the right program. We have to think a little bit about what we're doing.”
The program search failed because it was supplied with too much ambient information without appropriate constraints. Brady explains that transposing a matrix inherently consumes the input matrix exactly once. By annotating the input with quantity `1` (linear consumption), the compiler is barred from erroneously passing the already-consumed vector back into the helper, forcing the interactive generator to construct the valid terminating traversal. Brady points out to the audience that this helper is conceptually just `zipWith`:
> “In my dreams, in the dream version of this system, you'll sort of get to the end of this and the machine will say, you know, Clippy will pop up and say 'It looks like you're implementing zipWith again, would you like me to refactor that for you?'”
- Idris 2 requires explicit quantification if a type-level parameter must persist at runtime. - Interactive code search does not yet run an integrated termination checker during proof synthesis. - Linear quantities narrow the candidate space for automatic program synthesis by forbidding the reuse of spent arguments.
---
[24:45](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=1485s) Chez Scheme Code Generation and Performance
To demonstrate that the transposed matrix code actually executes, Brady executes the compiled program using `:exec` inside the REPL, printing out both original and transposed vectors. Under the hood, Idris 2 emits code targeted to Chez Scheme:
> “It turns out that Chez Scheme is astonishingly fast, so even from source, the Chez Scheme generated version for the small set of benchmarks I've tried has run faster than the Idris 1 which goes via C.”
Chez Scheme was maintained and refined at Cisco for several decades before being open-sourced. Brady observes that leveraging thirty years of dedicated compiler and runtime engineering provides substantial performance dividends out of the box, noting with a chuckle that having runtime experts optimize an execution environment is invaluable for a language creator.
- Idris 2 targets Chez Scheme as its execution engine rather than emitting C like Idris 1. - Initial benchmarks show Chez Scheme outperforming the older C backend of Idris 1. - Brady humorously invites experienced runtime engineers in the audience to collaborate on the Idris 2 compiler backend.
---
[26:12](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=1572s) Resource Tracking and Linear Protocol Verification
With roughly ten to fifteen minutes remaining, Brady introduces resource tracking via Quantitative Type Theory (QTT). While implementing complex type-level states can be punishing when an author must satisfy the type-checker all at once, Brady argues that interactive development turns it into an approachable, step-by-step dialogue. To demonstrate, he showcases an embedded domain-specific language for linear operations (resembling a linear IO monad) that models safe protocol transitions.
```mermaid flowchart LR accTitle: Door Protocol State Transitions accDescr: Finite state transitions of a door tracked by linear types, branching on operation success. Closed["Door Closed (Quantity 1)"] Knocked["Door Closed (d prime)"] Res{"openDoor Result"} Open["Door Open (True)"] Failed["Door Closed (False)"] Del["Deleted / Resource Spent"]
Closed -->|"knock"| Knocked Knocked -->|"openDoor"| Res Res -->|"True"| Open Res -->|"False"| Failed Open -->|"close & delete"| Del Failed -->|"deleteDoor"| Del ```
Using a door protocol as an intuitive example, actions like opening or closing are tracked with linear guarantees. Because real-world side effects can fail unexpectedly, the action `openDoor` returns a dependent pair (written as `Res`) containing a boolean flag and a door whose resulting typestate depends on that flag:
> “So D is still a closed door, but it's a closed door that we had in the past; D prime is the closed door that we have now, so we can't work with D anymore. We can still talk about it, we can still talk about the glorious history of how the door was before we knocked on it, but we can't have that door as before we knocked on it.”
Brady interacts with the compiler using holes and case-splitting: 1. `newDoor` returns a linear handle `D` with state `Closed` and quantity `1`. 2. Invoking `knock D` invalidates `D` and returns an updated handle `D'`. 3. Calling `openDoor D'` returns a dependent result pair `(x ** y)` where `x` is a `Bool`. 4. Case-splitting on `x` splits execution: if `True`, `y` is proven at compile time to be in state `Open`; if `False`, `y` remains `Closed`. 5. Because every resource marked with quantity `1` must be consumed before a function returns, the branch where the door failed to open cannot simply terminate; the linear handle must be explicitly disposed of with `deleteDoor`.
Brady completes the door program cleanly and transitions to using the same linear framework to demonstrate concurrency and session types in the talk's final minutes.
[31:51](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=1911s) Session Types and Protocols via Dependent Linear Types
Edwin Brady demonstrates how communication protocols can be specified directly in Idris 2 using global session types. Because Idris possesses the full expressive power of dependent types, describing protocols requires nothing beyond sequencing and dependency. Any protocol branching or choice can be represented straightforwardly with standard Idris language operators. He outlines a toy protocol between a client and a server: the client first sends a boolean value across a channel; if the boolean is `True`, the server responds with a character, whereas if the boolean is `False`, the server responds with a string.
```mermaid flowchart TD accTitle: Protocol Decision Flow accDescr: Client sends a boolean over a channel branching to receive either a character or a string based on the value. Start["Client sends Bool"] --> Choice{"Bool value?"} Choice -->|"True"| RecvChar["Server sends Char<br/>(Client receives Char)"] Choice -->|"False"| RecvString["Server sends String<br/>(Client receives String)"] ```
To demonstrate how the type checker guides development, Brady interacts with an incomplete client implementation using a typed hole in his editor. The channel type tracks the exact state of communication. Initially, the channel demands that a boolean be sent. Once a boolean literal `False` is supplied, querying the hole reveals that the next operation on the channel must be receiving a string. If `True` is sent instead, the type system updates to expect a character. Brady emphasizes that this fine-grained feedback enables step-by-step interactive construction rather than having to conceptualize and write the entire program at once.
He notes that this capability hints at the power of programmable program search: > “It might be that you want to write kind of special-purpose tactics for, okay, I want to do the protocol thing now, do me the next thing in the protocol; that's not ready yet, that's not something we have a language for expressing yet, I would love to have a language for expressing that.”
- In the demo client, Brady mentions having previously added a `sleep` call just to convince himself everything was running concurrently as expected, though it is not strictly needed for protocol adherence. - In complex programs with multiple active protocols or distinct resources, specialized domain-specific tactics could allow developers to automate next protocol steps while reserving manual code edits for ordinary application logic.
---
[35:00](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=2100s) Type Checking Violations and Protocol Evolution
Brady deliberately introduces errors into the protocol code to verify that the type checker catches protocol violations. In the first test, the client sends `True` (which dictates that a `Char` will follow), but the client code immediately attempts to append the incoming message to another string using string append. Because string append enforces that its operands are strings, the type checker flags an immediate type mismatch between `Char` and `String`. Brady jokes, “Hopefully won't type check, because if this type checks and everything about this is a lie... Oh, thank God for that!” While the compiler successfully flags the error, Brady acknowledges that the raw error diagnostics can still be unpolished and that the source location points to the append operation rather than the exact upstream branching mistake.
Next, he simulates changing requirements for a production protocol. Imagining the protocol was sold as a “million-dollar business,” he modifies the global protocol specification so that sending `False` requires the server to send an integer following the string. When checking the un-updated server against this new definition, the Idris 2 compiler rejects the implementation, alerting the developer that the channel was closed prematurely while an integer was still expected to be transmitted.
Brady highlights that implementing session types becomes remarkably direct once dependent linear types are available: > “One thing I found really nice is that it turns out if you have dependent linear types then it's a natural thing to be able to express.”
---
[37:08](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=2228s) Project Status, Quantitative Type Theory, and Future Work
Wrapping up the presentation with his summary slide, Brady reviews the current status of Idris 2. The compiler is progressing rapidly, and he is thoroughly enjoying development—largely because he no longer has to wait endlessly for the type checker to finish running. Most Idris 1 language constructs have been brought over, but several minor incompatibilities remain, meaning the system cannot immediately flick a switch to achieve full self-hosting.
Brady explains that his work with Quantitative Type Theory (QTT) is still in its infancy, noting that the talk showcased essentially everything he had implemented so far. He stresses that interactive editing must remain fast and fluid: > “I want this to be the default mode in which people interact with the system; if that's going to be the case, it has to come back with the answer very quickly, so I think we need to put a lot of that effort into efficiency that we just haven't so far.”
He invites the community to contribute across various areas: - Writing libraries and developing package management tooling. - Improving text editor plugins, cheekily noting to the audience: “I prefer to be using Vim than Atom, sorry I said that out loud to the Emacs users, but there you have it.” - Polishing compiler error reporting and adding tab-completion support. - Reading `CONTRIBUTING.md` on the GitHub repository for guidance on getting started in the codebase.
---
[39:27](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=2367s) Q&A: Linear Elements in Dependent Pairs
During the brief audience question period, an attendee asks about the earlier door-state example involving a dependent pair `(x ** y)` where `y` was linear but `x` was unrestricted: > “In your door example I have a quick question: the dependent pair you had `(x ** y)` and `y` was linear whereas `x` was not, quite work out why that is?”
Brady explains that the behavior comes directly from how the custom dependent pair type is defined. In Quantitative Type Theory, types can specify individual multiplicities for each field: > “That's because I didn't show you the definition of that type, and it's because I say in the type, the first thing is not linear, but the second thing is.”
Brady admits with a laugh that he wished he had a more magical or profound theoretical explanation, but it simply comes down to the explicit multiplicity annotations chosen in the type constructor definition. The session concludes with audience applause.
## Notable quotes > [02:55](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=175s) I don't want you to think Idris is shouting at you, Idris is trying to help you, it's trying to be in a conversation with you — Edwin Brady
> [10:07](https://www.youtube.com/watch?v=DRq2NgeFcO0&t=607s) I sort of feel like if we go to the trouble of expressing a predicate that says that a value at a particular location is a particular type, surely we've done enough work to write the program that pulls that value out of the list. — Edwin Brady
## Mentioned Edwin Brady, Idris, Idris 2, Quantitative Type Theory (QTT), Conor McBride, Bob Atkey, Kohei Honda, Linear Haskell, Djinn, Roy Dyckhoff, Chez Scheme, Cisco, Vim, Atom, Emacs
[Source](https://www.youtube.com/watch?v=DRq2NgeFcO0)