Coherence of Type Class Resolution

07/01/2019
by   Gert-Jan Bottu, et al.
0

Elaboration-based type class resolution, as found in languages like Haskell, Mercury and PureScript, is generally nondeterministic: there can be multiple ways to satisfy a wanted constraint in terms of global instances and locally given constraints. Coherence is the key property that keeps this sane; it guarantees that, despite the nondeterminism, programs still behave predictably. Even though elaboration-based resolution is generally assumed coherent, as far as we know, there is no formal proof of this property in the presence of sources of nondeterminism, like superclasses and flexible contexts. This paper provides a formal proof to remedy the situation. The proof is non-trivial because the semantics elaborates resolution into a target language where different elaborations can be distinguished by contexts that do not have a source language counterpart. Inspired by the notion of full abstraction, we present a two-step strategy that first elaborates nondeterministically into an intermediate language that preserves contextual equivalence, and then deterministically elaborates from there into the target language. We use an approach based on logical relations to establish contextual equivalence and thus coherence for the first step of elaboration, while the second step's determinism straightforwardly preserves this coherence property.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
10/25/2017

Logical relations for coherence of effect subtyping

A coercion semantics of a programming language with subtyping is typical...
research
07/12/2018

Journey Beyond Full Abstraction: Exploring Robust Property Preservation for Secure Compilation

Good programming languages provide helpful abstractions for writing secu...
research
07/30/2018

Coherent Explicit Dictionary Application for Haskell: Formalisation and Coherence Proof

Type classes are one of Haskell's most popular features and extend its t...
research
10/02/2018

Proof nets, coends and the Yoneda isomorphism

Proof nets provide permutation-independent representations of proofs and...
research
01/13/2022

The Combinatorics of Salva Veritate Principles

Various concepts of grammatical compositionality arise in many theories ...
research
10/12/2020

Joint Semantic Analysis with Document-Level Cross-Task Coherence Rewards

Coreference resolution and semantic role labeling are NLP tasks that cap...
research
12/05/2022

Equivalence of eval-readback and eval-apply big-step evaluators by regimentation of the lambda-calculus's strategy space

We study the equivalence of eval-readback and eval-apply big-step evalua...

Please sign up or login with your details

Forgot password? Click here to reset