arrow
Return

Heapless Functional Programming

delete2026-01-01
delete0
PRE
AI
E
Ellis Kesterton *
E
Edwin Brady
DOI:10.1007/978-3-031-99751-8_4delete
deleteOriginal
deleteOriginal request for help
deleteShare
deleteSave
Abstract

Abstract

En 中文
Typed functional programming languages like Haskell and OCaml make heavy use of the heap at run-time. This makes them largely unsuitable for systems programming, where resources are limited and programs are often expected to run on bare-metal. This paper demonstrates how a (slightly restricted) high-level, pure, functional language can be compiled to machine code which does not use the heap at all. Despite usually requiring a heap at run-time, features such as higher-order functions, polymorphism and typeclasses are all supported by the surface language. This is made possible through partial evaluation [12]: by carefully reducing the program at compile-time, we can eliminate these highlevel features entirely, resulting in a residual program which is trivial to compile to stack-based machine code. This paper describes the operation of this partial evaluator, justifies its design, and introduces a novel type system which guarantees that the partial evaluator will always succeed in removing all heap-using features.
Keywords:
functional programming
partial evaluation
heap-free compilation
type system
stack-based code

Journal

T
TRENDS IN FUNCTIONAL PROGRAMMING, TFP 2025
IF:
0
Papers:
20
Citations:
0

Organization

U
university of st andrews
Scholars:
9.5K
Papers: 1.0W
Citations: 15
Cited Papers

Cited Papers

errShare
errSave
err
IF0
err
err0
PREAI
err
errShare
errSave
Linear Haskell: practical linearity in a higher-order polymorphic language
err2017-12-27
err0
errOAAI
errJean-Philippe Bernardy; Mathieu Boespflug; Ryan R. Newton; Simon Peyton Jones; Arnaud Spiwack
errShare
errSave
The Simple Essence of Monomorphization
err2025-04-09
err0
PREAI
errLutze,Matthew; Schuster,Philipp; Brachthäuser,Jonathan Immanuel
errShare
errSave
Efficient compilation of algebraic effect handlers
err2021-10-20
err0
PREAI
errKarachalias,Georgios; Koprivec,Filip; Pretnar,Matija; Schrijvers,Tom
errShare
errSave
Kinds are calling conventions
err2020-08-02
err0
PREAI
errDownen,Paul; Ariola,Zena M.; Peyton Jones,Simon; Eisenberg,Richard A.
errShare
errSave
researcher View more