Hostname: page-component-77c78cf97d-9dm9z Total loading time: 0 Render date: 2026-04-23T12:57:05.531Z Has data issue: false hasContentIssue false

OCaml Blockly

Published online by Cambridge University Press:  28 April 2025

KENICHI ASAI*
Affiliation:
Department of Information Science, Ochanomizu University, Tokyo, Japan (e-mail: asai@is.ocha.ac.jp)
Rights & Permissions [Opens in a new window]

Abstract

OCaml Blockly is a block-based programming environment for a subset of the functional language OCaml, developed based on Google Blockly. The distinct feature of OCaml Blockly is that it knows the scoping and typing rules of OCaml. As such, for any complete program in OCaml Blockly, its OCaml counterpart compiles: it is free from syntax errors, scoping errors, and type errors. OCaml Blockly supports introductory constructs of OCaml that are sufficient to write the shortest path problem for the Tokyo metro network. This paper describes the design of OCaml Blockly and how it is used in a CS-major course on functional programming.

Information

Type
Education Matters
Creative Commons
Creative Common License - CCCreative Common License - BY
This is an Open Access article, distributed under the terms of the Creative Commons Attribution licence (https://creativecommons.org/licenses/by/4.0/), which permits unrestricted re-use, distribution and reproduction, provided the original article is properly cited.
Copyright
© The Author(s), 2025. Published by Cambridge University Press
Figure 0

Fig. 1. Variable, function, and type declaration.

Figure 1

Fig. 2. Polymorphic type checking for an identity function.

Figure 2

Fig. 3. Connector is disabled when its type is not defined.

Figure 3

Fig. 4. Passing add_a to List.map.

Figure 4

Fig. 5. OCaml Blockly.

Figure 5

Fig. 6. Opening a menu to drag and drop a block.

Figure 6

Fig. 7. Scope playground.

Figure 7

Fig. 8. Header and tests for a function discriminant. The type of discriminant is constrained by the test cases.

Figure 8

Fig. 9. A function numRS that returns the number of real solutions, given coefficients a, b, and c. Students never forget to pass arguments to discriminant.

Figure 9

Table 1. Syllabus for the functional programming course in Ochanomizu University. The rightmost column shows students’ perception towards writing the shortest path problem for the Tokyo metro network

Figure 10

Table 2. Number of students who enrolled, got credit of the course

Figure 11

Table 3. Questionnaire 1: when did you stop using OCaml Blockly?

Figure 12

Table 4. Questionnaire 2: was block interface useful?

Figure 13

Table 5. Questionnaire 3: do you feel the programming became easier (e.g., for understanding syntactic structure, typing) by using block interface?

Figure 14

Table 6. Questionnaire 4: do you feel your programming ability decreased (e.g., cannot live without block interface, cannot program in a text editor) because of the block interface?

Submit a response

Discussions

No Discussions have been published for this article.