Practical Optional Types for Clojure

Typed Clojure is an optional type system for Clojure, a dynamic language in the Lisp family that targets the JVM. Typed Clojure enables Clojure programmers to gain greater confidence in the correctness of their code via static type checking while remaining in the Clojure world, and has acquired significant adoption in the Clojure community. Typed Clojure repurposes Typed Racket's occurrence typing, an approach to statically reasoning about predicate tests, and also includes several new type system features to handle existing Clojure idioms. In this paper, we describe Typed Clojure and present these type system extensions, focusing on three features widely used in Clojure. First, multimethods provide extensible operations, and their Clojure semantics turns out to have a surprising synergy with the underlying occurrence typing framework. Second, Java interoperability is central to Clojure's mission but introduces challenges such as ubiquitous null; Typed Clojure handles Java interoperability while ensuring the absence of null-pointer exceptions in typed programs. Third, Clojure programmers idiomatically use immutable dictionaries for data structures; Typed Clojure handles this with multiple forms of heterogeneous dictionary types. We provide a formal model of the Typed Clojure type system incorporating these and other features, with a proof of soundness. Additionally, Typed Clojure is now in use by numerous corporations and developers working with Clojure, and we present a quantitative analysis on the use of type system features in two substantial code bases.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
07/03/2019

NullAway: Practical Type-Based Null Safety for Java

NullPointerExceptions (NPEs) are a key source of crashes in modern Java ...
research
02/28/2020

Behavioural Types for Memory and Method Safety in a Core Object-Oriented Language

We present a type-based analysis ensuring memory safety and object proto...
research
06/28/2019

Pinpointing Performance Inefficiencies in Java

Many performance inefficiencies such as inappropriate choice of algorith...
research
12/04/2022

Differential Testing of a Verification Framework for Compiler Optimizations (Experience Paper)

We want to verify the correctness of optimization phases in the GraalVM ...
research
10/07/2020

Type checking extracted methods

Many object-oriented dynamic languages allow programmers to extract meth...
research
01/15/2018

Java & Lambda: a Featherweight Story

We present FJ&Lambda, a new core calculus that extends Featherweight Jav...
research
11/19/2021

A Transient Semantics for Typed Racket

Mixed-typed languages enable programmers to link typed and untyped compo...

Please sign up or login with your details

Forgot password? Click here to reset