Filling the Gaps of Polarity: Implementing Dependent Data and Codata Types with Implicit Arguments

Bohdan Liesnikov1 OrcidLogo, David Binder2 OrcidLogo, and Tim Süberkrüb3 OrcidLogo

The Art, Science, and Engineering of Programming, 2025, Vol. 10, Issue 3, Article 19

Submission date: 2025-06-02
Publication date: 2025-10-15
DOI: https://doi.org/10.22152/programming-journal.org/2025/10/19
Full text: t.b.a

Abstract

The expression problem describes a fundamental tradeoff between two types of extensibility: extending a type with new operations, such as by pattern matching on an algebraic data type in functional programming, and extending a type with new constructors, such as by adding a new object implementing an interface in object-oriented programming. Most dependently typed languages have good support for the former style through inductive types, but support for the latter style through coinductive types is usually much poorer. Polarity is a language that treats both kinds of types symmetrically and allows the developer to switch between type representations.However, it currently lacks several features expected of a state-of-the-art dependently typed language, such as implicit arguments. The central aim of this paper is to provide an algorithmic type system and inference algorithm for implicit arguments that respect the core symmetry of the language. Our work provides two key contributions: a complete algorithmic description of the type system backing Polarity, and a comprehensive description of a unification algorithm that covers arbitrary inductive and coinductive types. We give rules for reduction semantics, conversion checking, and a unification algorithm for pattern-matching, which are essential for a usable implementation. A work-in-progress implementation of the algorithms in this paper is available at polarity-lang.github.io. We expect that the comprehensive account of the unification algorithm and our design decisions can serve as a blueprint for other dependently typed languages that support inductive and coinductive types symmetrically.

  1. Delft University of Technology, Netherlands
    OrcidLogo https://orcid.org/0009-0000-2216-8830

  2. University of Kent, Canterbury, UK
    OrcidLogo https://orcid.org/0000-0003-1272-0972

  3. University of Tübingen, Germany
    OrcidLogo https://orcid.org/0000-0001-8709-6321