Type Inference of Simple Recursive Functions in Scala

Keywords: Scala, type inference, recursion

Abstract

Scala is a well-established multi-paradigm programming language known for its terseness that includes advanced type inference features. Unfortunately this type inferring algorithm does not support typing of recursive functions. This is both against the original design philosophies of Scala and puts an unnecessary burden on the programmer. In this paper we propose a method to compute the return types for simple recursive functions in Scala. We make a heuristic assumption on the return type based on the non-recursive execution branches and provide a proof of this method's correctness. The algorithm does not have a significant effect on the compilation speed. We implemented our method as an extension prototype in the Scala compiler and used it to successfully test our method on various examples. The compiler extension prototype is available for further tests.

Downloads

Download data is not yet available.
Published
2020-10-22
How to Cite
Nagy, G., OláhG., & PorkolábZ. (2020). Type Inference of Simple Recursive Functions in Scala. Acta Cybernetica. https://doi.org/10.14232/actacyb.282762
Section
Selected papers of STCS 2019