[Paper Review] A Framework for Resource Dependent EDSLs in a Dependently Typed Language (Pearl)
This paper presents Dependent Haskell, a backward-compatible extension to Haskell that enables full dependent types through a novel type system and compilation pipeline. It introduces the Pico language as an intermediate representation and the Bake type inference and elaboration algorithm, proving type safety and soundness, enabling practical, verified programs with rich static guarantees.
Haskell, as implemented in the Glasgow Haskell Compiler (GHC), has been adding new type-level programming features for some time. Many of these features---chiefly: generalized algebraic datatypes (GADTs), type families, kind polymorphism, and promoted datatypes---have brought Haskell to the doorstep of dependent types. Many dependently typed programs can even currently be encoded, but often the constructions are painful. In this dissertation, I describe Dependent Haskell, which supports full dependent types via a backward-compatible extension to today's Haskell. An important contribution of this work is an implementation, in GHC, of a portion of Dependent Haskell, with the rest to follow. The features I have implemented are already released, in GHC 8.0. This dissertation contains several practical examples of Dependent Haskell code, a full description of the differences between Dependent Haskell and today's Haskell, a novel type-safe dependently typed lambda-calculus (called Pico) suitable for use as an intermediate language for compiling Dependent Haskell, and a type inference and elaboration algorithm, Bake, that translates Dependent Haskell to type-correct Pico.
Motivation & Objective
- To design and implement a backward-compatible extension to Haskell that supports full dependent types.
- To provide a practical, type-safe foundation for dependently typed programming in a widely used functional language.
- To formalize the type system and type inference process through a novel intermediate language (Pico) and elaboration algorithm (Bake).
- To prove the type safety of Pico and the soundness of Bake, ensuring correct compilation of dependent types.
- To enable practical applications such as length-indexed vectors, type-safe database access, and strongly-typed interpreters.
Proposed method
- Designing a dependently typed lambda calculus called Pico as an intermediate language for compiling Dependent Haskell.
- Defining a type inference and elaboration algorithm, Bake, that translates Dependent Haskell code into well-typed Pico expressions.
- Introducing a novel type equivalence relation ≡ and extraction operator →≡ to support type-level computation and reasoning.
- Using a relational representation of contexts (Rel(Γ)) to model type-level dependencies and ensure correctness during elaboration.
- Proving type safety of Pico via structural induction on typing derivations and formal type system properties.
- Establishing soundness of Bake through a series of lemmas showing that well-typed Pico≡ derivations map to well-typed Pico derivations under the ⌈·⌉ operation.
Experimental results
Research questions
- RQ1How can full dependent types be added to Haskell in a backward-compatible way?
- RQ2What intermediate language is suitable for compiling dependently typed programs while preserving type safety?
- RQ3How can type inference and elaboration be soundly performed in the presence of type-level functions and dependent types?
- RQ4What formal properties (e.g., type safety, soundness) can be proven for a dependently typed intermediate language and its compilation pipeline?
- RQ5Can practical, real-world programs (e.g., type-safe interpreters, algebraic effects) be expressed and verified in this extended type system?
Key findings
- The Pico language provides a minimal, formally-sound intermediate representation for dependently typed programs, with a well-defined type system and formal proofs of type safety.
- The Bake algorithm successfully translates Dependent Haskell code into well-typed Pico expressions, with soundness proven via a series of lemmas on context, type, and coercion lifting.
- The ⌈·⌉ operation correctly maps well-typed Pico≡ derivations to equivalent Pico derivations, preserving types and coercions under the ≡ and →≡ relations.
- The framework enables practical applications such as length-indexed vectors, type-safe database access, and strongly-typed interpreters, demonstrating real-world feasibility.
- Formal proofs of type safety for Pico and soundness of Bake are included in the appendix, establishing a solid theoretical foundation for the system.
- The implementation of key features (e.g., GADTs, type families, kind polymorphism) in GHC 8.0 confirms the practical viability of the approach.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.