Many Haskell textbooks explain the evaluation of pure functional programs as a process of stepwise rewriting using equations. However, usual implementation techniques perform program transformations that make producing the corresponding tracing evaluations difficult. This paper presents a tracing interpreter for a subset of Haskell based on the pattern matching calculus of Kahl. We start from a big-step semantics in the style of Launchbury and develop a small-step semantics in the style of Sestoft's machines. This machine is used in the implementation of a step-by-step educational interpreter. We also discuss some implementation decisions and present illustrative examples.
翻译:许多Haskell教科书将纯函数式程序的求值过程解释为基于方程的逐步重写过程。然而,常规实现技术所执行的程序变换使得生成对应的追踪求值过程变得困难。本文提出了一种基于Kahl模式匹配演算的Haskell子集追踪解释器。我们从Launchbury风格的大步语义出发,发展出Sestoft机器风格的小步语义。该机器被用于实现一个逐步教学解释器。我们还讨论了若干实现决策,并展示了说明性示例。