Revisiting Catamorphisms over Datatypes with Embedded Functions

نویسندگان

  • Leonidas Fegaras
  • Tim Sheard
چکیده

We revisit the work of Paterson and of Meijer & Hutton, which describes how to construct catamorphisms for recur-sive datatype deenitions that embed contravariant occurrences of the type being deened. Their construction requires , for each catamorphism, the deenition of an anamor-phism that has an inverse-like relationship to that cata-morphism. We present an alternative construction, which replaces the stringent requirement that an inverse anamor-phism be deened for each catamorphism with a more lenient restriction. The resulting construction has a more eecient implementation than that of Paterson, Meijer, and Hutton and the relevant restriction can be enforced by a Hindley-Milner type inference algorithm. We provide numerous examples illustrating our method.

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

ثبت نام

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

منابع مشابه

Ranking Catamorphisms and Unranking Anamorphisms on Hereditarily Finite Datatypes

Using specializations of unfold and fold on a generic tree data type we derive unranking and ranking functions providing natural number encodings for various Hereditarily Finite datatypes. In this context, we interpret unranking operations as instances of a generic anamorphism and ranking operations as instances of the corresponding catamorphism. Starting with Ackerman’s Encoding from Hereditar...

متن کامل

An Improved Unrolling-Based Decision Procedure for Algebraic Data Types

Reasoning about algebraic data types and functions that operate over these data types is an important problem for a large variety of applications. In this paper, we present a decision procedure for reasoning about data types using abstractions that are provided by catamorphisms: fold functions that map instances of algebraic data types into values in a decidable domain. We show that the procedu...

متن کامل

Using monads to fuse recursive programs

We try to combine the ‘syntactic composition of tree transducers’ [FV98, KV01] on the one hand side and ‘short cut fusion’ [GLP93] on the other hand side. Short cut fusion is based on the ‘cata/build-rule’ [Joh01] or ‘acid rain theorem’ [TM95]. Therefore it is necessary to represent the recursive functions as catamorphisms. A catamorphism is a generalization of the well known list-function fold...

متن کامل

Polytypic Programming

Many functions have to be written over and over again for different datatypes, either because datatypes change during the development of programs, or because functions with similar functionality are needed on diierent datatypes. Examples of such functions are pretty printers, debug-gers, equality functions, uniiers, pattern matchers, rewriting functions, etc. Such functions are called polytypic...

متن کامل

Polytypic Functions Over Nested Datatypes

The theory and practice of polytypic programming is intimately connected with the initial algebra semantics of datatypes. This is both a blessing and a curse. It is a blessing because the underlying theory is beautiful and well developed. It is a curse because the initial algebra semantics is restricted to so-called regular datatypes. Recent work by R. Bird and L. Meertens [3] on the semantics ...

متن کامل

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


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

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 1996