In this position paper, we present a prototype of a visualizer for functional programs. Such programs, whose evaluation model is the reduction of an expression to a value through repeated application of rewriting rules, and which tend to make little or no use of mutable state, are amenable to visualization in the same fashion as simple mathematical expressions, with which every schoolchild is familiar. We show how such visualizations may be produced for the strict functional language OCaml, by direct interpretation of the abstract syntax tree and appropriate pretty-printing. We describe (and begin to address) the challenges of presenting such program traces in limited space and of identifying their essential elements, so that our methods will one day be practical for more than toy programs. We consider the problems posed by the parts of modern functional programming which are not purely functional such as mutable state, input/output and exceptions. We describe initial work on the use of such visualizations to address the problem of program debugging, which is our ultimate aim.
翻译:在这篇立场论文中,我们展示了一个函数式程序可视化工具的原型。这类程序的评估模型是通过重写规则的重复应用将表达式归约为值,且往往很少或完全不使用可变状态,因此可以采用与简单数学表达式相同的方式进行可视化——这种可视化方式每个学童都熟悉。我们展示了如何通过直接解释抽象语法树并进行适当的格式化输出,为严格函数式语言OCaml生成此类可视化。我们描述(并开始解决)在有限空间内呈现此类程序轨迹以及识别其核心要素所面临的挑战,以使我们的方法有朝一日能超越玩具程序的实际应用。我们探讨了现代函数式编程中非纯函数式部分(如可变状态、输入/输出和异常)带来的问题。我们介绍了利用此类可视化解决程序调试问题的初步工作,这亦是我们的最终目标。