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.4K
Papers: 1.0W
Citations: 15