Polytypic syntax tree operations

  • Authors:
  • Arjen van Weelden;Sjaak Smetsers;Rinus Plasmeijer

  • Affiliations:
  • Institute for Computing and Information Sciences, Radboud University Nijmegen, The Netherlands;Institute for Computing and Information Sciences, Radboud University Nijmegen, The Netherlands;Institute for Computing and Information Sciences, Radboud University Nijmegen, The Netherlands

  • Venue:
  • IFL'05 Proceedings of the 17th international conference on Implementation and Application of Functional Languages
  • Year:
  • 2005

Quantified Score

Hi-index 0.00

Visualization

Abstract

Polytypic functional programming has the advantage that it can derive code for generic functions automatically. However, it is not clear whether it is useful for anything other than the textbook examples, and the generated polytypic code is usually too slow for real-life programs. As a real-life test, we derive a polytypic parser for the Haskell 98 syntax and look into other front-end compiler syntax tree operations. We present a types–as–grammar approach, which uses polytypic programming (in both Generic Haskell and Clean) to automatically derive the code for a parser based on the syntax tree type, without using external tools. Moreover, we show that using polytypic programming can even be useful for data–specific syntax tree operations in a (functional) compiler, such as scope checking and type inference. Simple speed tests show that the performance of polytypic parsers can be abominable for real-life inputs. However, we show that much performance can be recovered by applying (extended) fusion optimization on the generated code. We actually have a derived parser whose speed is close to one generated by a specialized Haskell parser generator.