Abstract
Function composition is a very natural operation, but most language paradigms provide poor support for it. Without linguistic support programmers must work around or manually implement what would be simple compositions. The Kihi language uses only composition, makes all state visible, and reduces to just six core operations. Kihi programs are easily stepped by textual reduction but provide a foundation for compositional design and analysis.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
References
Curry, H.B.: Grundlagen der kombinatorischen logik. Am. J. Math. 52(3), 509–536 (1930)
Erb, J.: Om programming language web site. https://sparist.github.io/Om/
Felleisen, M., Findler, R.B., Flatt, M.: Semantics Engineering with PLT Redex. MIT Press, Cambridge (2009)
Frenger, P.: The JOY of forth. SIGPLAN Not. 38(8), 15–17 (2003). https://doi.org/10.1145/944579.944583
Homer, M., Noble, J.: A tile-based editor for a textual programming language. In: VISSOFT 2013, pp. 1–4, September 2013. https://doi.org/10.1109/VISSOFT.2013.6650546
Homer, M., Bruce, K.B., Noble, J., Black, A.P.: Modules as gradually-typed objects. In: DYLA 2013. ACM (2013). https://doi.org/10.1145/2489798.2489799
Jones, T., Homer, M., Noble, J.: Brand objects for nominal typing. In: ECOOP 2015. LIPIcs, Dagstuhl, Germany, vol. 37, pp. 198–221 (2015). https://doi.org/10.4230/LIPIcs.ECOOP.2015.198
Jones, T., Homer, M., Noble, J., Bruce, K.: Object inheritance without classes. In: ECOOP 2016. LIPIcs, Dagstuhl, Germany , vol. 56, pp. 13:1–13:26 (2016). https://doi.org/10.4230/LIPIcs.ECOOP.2016.13
Krivine, J.L.: A call-by-name lambda-calculus machine. Higher Order Symbol. Comput. 20(3), 199–207 (2007). https://doi.org/10.1007/s10990-007-9018-9
Moore, C.: 1x Forth (1999)
Post, E.L.: Formal reductions of the general combinatorial decision problem. Am. J. Math. 65(2), 197–215 (1943)
von Thun, M., Thomas, R.: Joy: forth’s functional cousin. In: Proceedings of the 17th EuroForth Conference (2001)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Screenshots and Outline
Screenshots and Outline
This appendix provides tool screenshots, identifies various features, and notes points of behaviour that are incorporated in the demonstration.
1.1 Overall View of Web Evaluator
The top row includes, from left to right:
-
1.
A text box for entering a Kihi program to evaluate;
-
2.
A button that executes the program;
-
3.
A button that translates the given program into core operations, expanding binds and named terms;
-
4.
A button that shrinks excess terms inside abstractions.
The second row provides buttons for the operator symbols. The third is the output area, showing the final result value of the program and any values emitted by the evaluation.
The check boxes, from left to right:
-
1.
Select the leftmost available reduction (checked) or the rightmost available reduction (unchecked);
-
2.
Enable evaluation of the program without clicking “Run”;
-
3.
Remove values reaching the left-hand edge and move them to the output area;
-
4.
Render operators as names (e.g. right) instead of symbols ();
-
5.
Sugar outputted Church numerals into textual numbers;
-
6.
Render operators using substitute ASCII symbols (e.g. :) instead of mathematical symbols (\(\mathtt {\times }\)). This mode suits some limited browsers and systems.
The step limit determines the maximum number of reduction steps the evaluator will take before stopping. It also stops if a program becomes too long. These stopping points are to preserve browser resources. In particular, programs with nested binds (as in the provided factorial example program) can expand to many thousands of terms of core Kihi, and creating the list of steps performs very poorly. This is a limitation of the web evaluator.
The fourth row allows manual stepping through the evaluation: jumping to a specific numbered step (left), dragging the slider through steps (middle), or automatically replaying and pausing evaluation (right).
The black box shows the current program being evaluated at this step, depicted and described in more detail in the next section.
The “Steps” heading shows the total number of steps, and acts to hide or restore the complete list of reduction steps below. The filter text box permits showing only a subset of steps: for example, entering “left” will make only “left” reduction steps appear.
The list of steps shows the program as it is at each step, underlining any new terms introduced at that step and marking the rule used to obtain them. Hovering the mouse over the rule will show a detailed display of the specific reduction. The terms to be reduced next are highlighted in blue; it is possible for portions of the program to be both new (underlined) and to-be-reduced (blue) at once. Clicking on a step jumps the display above to that step of the program.
A labelled list of sample programs is below, any of which can be loaded and evaluated by clicking the title.
1.2 Single-Step Display of Web Evaluator
The complete program at this step is displayed at the top, with the rule that produced it displayed below. The underlined text in the program is that on the right-hand side of the rule display, and blue text is the next to be expanded as before. The rule display highlights different elements of the rule (for example, arguments) and matches corresponding elements on each side with the same highlighting.
Rights and permissions
Copyright information
© 2018 Springer Nature Switzerland AG
About this paper
Cite this paper
Jones, T., Homer, M. (2018). The Practice of a Compositional Functional Programming Language. In: Ryu, S. (eds) Programming Languages and Systems. APLAS 2018. Lecture Notes in Computer Science(), vol 11275. Springer, Cham. https://doi.org/10.1007/978-3-030-02768-1_10
Download citation
DOI: https://doi.org/10.1007/978-3-030-02768-1_10
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-02767-4
Online ISBN: 978-3-030-02768-1
eBook Packages: Computer ScienceComputer Science (R0)