DeepAI AI Chat
Log In Sign Up

Bidirectional Type Class Instances (Extended Version)

06/28/2019
by   Koen Pauwels, et al.
0

GADTs were introduced in Haskell's eco-system more than a decade ago, but their interaction with several mainstream features such as type classes and functional dependencies has a lot of room for improvement. More specifically, for some GADTs it can be surprisingly difficult to provide an instance for even the simplest of type classes. In this paper we identify the source of this shortcoming and address it by introducing a conservative extension to Haskell's type classes: Bidirectional Type Class Instances. In essence, under our interpretation class instances correspond to logical bi-implications, in contrast to their traditional unidirectional interpretation. We present a fully-fledged design of bidirectional instances, covering the specification of typing and elaboration into System FC, as well as an algorithm for type inference and elaboration. We provide a proof-of-concept implementation of our algorithm, and revisit the meta-theory of type classes in the presence of our extension.

READ FULL TEXT

page 1

page 2

page 3

page 4

04/29/2020

Models of Homotopy Type Theory with an Interval Type

In this short note, we construct a class of models of an extension of ho...
08/16/2019

Bidirectional Typing

Bidirectional typing combines two modes of typing: type checking, which ...
05/25/2018

Spine-local Type Inference

We present spine-local type inference, a partial type inference system f...
07/01/2020

Equational Reasoning for MTL Type Classes

Ability to use definitions occurring in the code directly in equational ...
08/17/2018

Proving Type Class Laws for Haskell

Type classes in Haskell are used to implement ad-hoc polymorphism, i.e. ...
06/09/2018

Type variables in patterns

For many years, GHC has implemented an extension to Haskell that allows ...
12/20/2019

Next Priority Concept: A new and generic algorithm computing concepts from complex and heterogeneous data

In this article, we present a new data type agnostic algorithm calculati...