ResearchBib Share Your Research, Maximize Your Social Impacts
Sign for Notice Everyday Sign up >> Login

Generic programming with combinators and objects

Journal: Scientific and Technical Journal of Information Technologies, Mechanics and Optics (Vol.21, No. 5)

Publication Date:

Authors : ;

Page : 720-726

Keywords : generic programming; functional programming;

Source : Downloadexternal Find it from : Google Scholarexternal

Abstract

The generic programming approach is popular in functional languages (for example, OCaml, Haskell). In essence, it is a compile-time generation of code that performs transformations of user-defined data types. The generated code can carry out various kinds of transformations of the values. Usually, transformations are represented as functions that implement algorithms of transformation. New transformations could be built from these transformation functions and user-defined ones. The representation based on functions has a downside: functions behave as final representations, and hence it is not possible to modify the behavior of the already built function. If the current set of transformations does not suit well, software developers are obliged to write a completely distinct transformation, even in the case when the new transformation is almost identical to the existing one. This work proposes to build transformations that are extensible afterconstruction.Theobject-orientedprogrammingparadigmwillbefollowed,transformations willberepresentednot as functions butas objects. Instead of calling atransformation function, oneof theobject's methods willbecalled. The transformation itself will be split into methods. The extensibility is supported by adding new methods and overriding existing ones. In this paper, the authors propose an approach to represent transformations as objects in the OCaml functional programming language. Every alternative in data type definition has a corresponding object method. This design allows the construction of many distinct transformations. The cases where too many methods are not desirable are also discussed. The method is applicableto representextensible transformations for polymorphicvariantdatatypes in OCaml when other methods fail to do it. The method is not bound to any particular domain. It allows the creation of extensible transformations in OCaml. It could be ported to other functional languages supporting object-oriented programming.

Last modified: 2021-10-21 20:01:11