Skip to Main content Skip to Navigation
Conference papers

Quantified Applicatives: API design for type-inference constraints

Olivier Martinot 1 Gabriel Scherer 2 
2 PARTOUT - Automatisation et ReprésenTation: fOndation du calcUl et de la déducTion
LIX - Laboratoire d'informatique de l'École polytechnique [Palaiseau], Inria Saclay - Ile de France
Abstract : The Inferno library (https://gitlab.inria.fr/fpottier/inferno) uses an applicative functor ('a co) to represent constraint-based inference problems that elaborate into explicitly-typed term representations. A central operation of the Inferno API is the `exist` quantifier, which generates a fresh inference variable scoped in an existential constraint. `exist` returns the result of solving the constraint, as well as the elaborated type inferred for the inference variable: val exist : (variable -> 'a co) -> ('a * ty) co We found that programming with this interface is difficult and leads to program that are hard to read. The difficulty is specific to applicative functors, there would be standard solutions with a monad. We report on our API design work to solve this issue. We start by explaining the programming difficulties and why the Inferno functor is not a monad, then a first experiment with a codensity monad, and finally a simpler solution that avoids mixing several functors in the same codebase. Our approach makes good use of the "binding operators" recently introduced in OCaml to provide flexible syntactic sugar for monad or applicative-like structures. We believe that the API design pattern we propose, "turning direct outputs into modal inputs", may apply to any applicative functors with quantifiers. It may already be in use, and its discussion may benefit other projects. Experience sharing with the ML Workshop audience could be very valuable.
Document type :
Conference papers
Complete list of metadata

https://hal.inria.fr/hal-03145040
Contributor : Scherer Gabriel Connect in order to contact the contributor
Submitted on : Thursday, February 18, 2021 - 9:29:59 AM
Last modification on : Friday, February 4, 2022 - 3:24:29 AM
Long-term archiving on: : Wednesday, May 19, 2021 - 6:27:55 PM

File

quantified-applicatives-worksh...
Files produced by the author(s)

Identifiers

  • HAL Id : hal-03145040, version 1

Citation

Olivier Martinot, Gabriel Scherer. Quantified Applicatives: API design for type-inference constraints. ML Family Workshop, Aug 2020, Jersey City / Online, United States. ⟨hal-03145040⟩

Share

Metrics

Record views

41

Files downloads

47