A functional approach to generic programming using adaptive traversals

نویسندگان

  • Bryan Chadwick
  • Karl J. Lieberherr
چکیده

Writing functions over complex user-defined datatypes can be tedious and error prone. Generic (or polytypic) programming and higher order functions like foldr have resolved some of these issues, but can be too general to be practically useful for larger collections of data types. In this paper we present a traversal-based approach to generic programming using function sets. Our traversal is an adaptive, higher-order function that employs an asymmetric type-based multiple dispatch to fold over arbitrarily complex structures. We introduce our approach in the context of our Scheme library implementation, present a typed model of our system, and provide a proof of type soundness, showing that our flexible, adaptive approach is both useful and safe.

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

A Generative Approach to Traversal-based Generic Programming

The development of complex software requires the implementation of functions over a variety of recursively defined data structures. Much of the corresponding code is not necessarily difficult, but more tedious and/or repetitive and sometimes easy to get wrong. Data structure traversals fall into this category, particularly in object-oriented languages where traversal code is spread throughout m...

متن کامل

Software ENgineering Strategic Programming Meets Adaptive Programming

Strategic programming is a generic programming idiom for processing compound data such as terms or object structures. At the heart of the approach is the separation of two concerns: basic data-processing computations vs. traversal schemes. Actual traversals can be composed by passing the former as arguments to the latter. Traversal schemes can be defined by the strategic programmer using a comb...

متن کامل

The Essence of Strategic Programming

Strategic programming is generic programming with the use of strategies. A strategy is a generic data-processing action which can traverse into heterogeneous data structures while mixing uniform and type-specific behaviour. With strategic programming, one gains full control over the application of basic actions, most notably full traversal control. Using a combinator style, traversal schemes ca...

متن کامل

The Kansas University rewrite engine - A Haskell-Embedded Strategic Programming Language with Custom Closed Universes

When writing transformation systems, a significant amount of engineering effort goes into setting up the infrastructure needed to direct individual transformations to specific targets in the data being transformed. Strategic programming languages provide general-purpose infrastructure for this task, which the author of a transformation system can use for any algebraic data structure. The Kansas...

متن کامل

Optimizing SYB traversals is easy!

The most widely used generic-programming system in the Haskell community, Scrap Your Boilerplate (SYB), also happens to be one of the slowest. Generic traversals in SYB are often an order of magnitude slower than equivalent handwritten, non-generic traversals. Thus while SYB allows the concise expression of many traversals, its use incurs a significant runtime cost. Existing techniques for opti...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:
  • Higher-Order and Symbolic Computation

دوره 23  شماره 

صفحات  -

تاریخ انتشار 2010