Unboxing Mutually Recursive Type Definitions in OCaml

11/06/2018
by   Simon Colin, et al.
0

In modern OCaml, single-argument datatype declarations (variants with a single constructor, records with a single field) can sometimes be `unboxed'. This means that their memory representation is the same as their single argument (omitting the variant or record constructor and an indirection), thus achieving better time and memory efficiency. However, in the case of generalized/guarded algebraic datatypes (GADTs), unboxing is not always possible due to a subtle assumption about the runtime representation of OCaml values. The current correctness check is incomplete, rejecting many valid definitions, in particular those involving mutually-recursive datatype declarations. In this paper, we explain the notion of separability as a semantic for the unboxing criterion, and propose a set of inference rules to check separability. From these inference rules, we derive a new implementation of the unboxing check that properly supports mutually-recursive definitions.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
11/20/2018

A right-to-left type system for mutually-recursive value definitions

In call-by-value languages, some mutually-recursive value definitions ca...
research
08/08/2018

Coaxioms: flexible coinductive definitions by inference systems

We introduce a generalized notion of inference system to support more fl...
research
01/23/2019

The Size-Change Principle for Mixed Inductive and Coinductive types

This paper describes how to use Lee, Jones and Ben Amram's size-change p...
research
07/25/2022

Evolving Recursive Definitions with Applications to Dynamic Programming

Inspired by computability logic<cit.>, we refine recursive function defi...
research
01/03/2022

let (rec) insertion without Effects, Lights or Magic

Let insertion in program generation is producing code with definitions (...
research
12/04/2017

Generalizing inference systems by coaxioms

After surveying classical results, we introduce a generalized notion of ...
research
07/05/2023

Runtime Repeated Recursion Unfolding: A Just-In-Time Online Program Optimization That Can Achieve Super-Linear Speedup

We introduce a just-in-time runtime program transformation based on repe...

Please sign up or login with your details

Forgot password? Click here to reset