This content originally appeared on HackerNoon and was authored by Abstraction: Computer Science Discourse
Table of Links
Translating To Sequent Calculus
Evaluation Within a Context
Insights
5.1 Evaluation Contexts are First Class
5.3 Let-Bindings are Dual to Control Operators
5.4 The Case-of-Case Transformation
5.5 Direct and Indirect Consumers
Conclusion, Data Availability Statement, and Acknowledgments
A. The Relationship to the Sequent Calculus
C. Operational Semantics of label/goto
4 Typing Rules
In this section, we introduce the typing rules for Fun in Section 4.1 and for Core in Section 4.2. In Section 4.3 we state type soundness for both languages and prove that the translation from Fun to Core preserves the typeability of programs. We use the same constructors, destructors, types and typing contexts for both Fun and Core, which are summarized in Definition 4.1. Note that we distinguish between producer and consumer variables in the typing contexts, which we indicate with the prd and cns annotations.
\
\ We specialize the rules for data types to the concrete types Pair and List, and the rules for codata types to LPair, Stream and functions 𝜎 → 𝜏. A realistic programming language would use type declarations introduced by the programmer to typecheck data and codata types instead of using these special cases. But the formalization of such a general mechanism for specifying data and codata types makes the typing rules less readable. This kind of mechanism for specifying algebraic data and codata types in sequent-calculus-based languages can be found in [Downen et al. 2015] or [Downen and Ariola 2020, section 8]. In all of the typing rules below we assume that we have a program environment which contains type declarations for all the definitions contained in the program, but don’t explicitly thread this program environment through each of the typing rules.
4.1 Typing Rules for Fun
We don’t discuss the typing rules for Fun in detail since they are mostly standard. Instead, we provide the full rules in Appendix B. The language Fun only has one syntactic category, terms, so we only need one typing judgment Γ ⊢ 𝑡 : 𝜏. This typing judgment says that in the context Γ (which contains type assignments for both variables and covariables) the term 𝑡 has type 𝜏. The only two interesting rules concern the control operators label and goto:
\
\
\ \ In the rule Goto we require that the covariable 𝛼 is in the context with type 𝜏, and that the term 𝑡 can be typechecked with the same type. The term goto(𝑡; 𝛼) itself can be used at any type 𝜏 ′ because it does not return to its immediately surrounding context.
\ \
:::info Authors:
(1) David Binder, University of Tübingen, Germany;
(2) Marco Tzschentke, University of Tübingen, Germany;
(3) Marius Muller, University of Tübingen, Germany;
(4) Klaus Ostermann, University of Tübingen, Germany.
:::
:::info This paper is available on arxiv under CC BY 4.0 license.
:::
\
This content originally appeared on HackerNoon and was authored by Abstraction: Computer Science Discourse

Abstraction: Computer Science Discourse | Sciencx (2025-07-08T07:00:02+00:00) Why Type Soundness Matters in Functional Programming Languages. Retrieved from https://www.scien.cx/2025/07/08/why-type-soundness-matters-in-functional-programming-languages/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.