Generic programming with combinators and objects
Journal: Scientific and Technical Journal of Information Technologies, Mechanics and Optics (Vol.21, No. 5)Publication Date: 2021-10-21
Authors : Kosarev D.S. Boulytchev D.Yu.;
Page : 720-726
Keywords : generic programming; functional programming;
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.
Other Latest Articles
- Pedagogical conditions for development of lyceum teachers’ professional culture in the methodical work system
- Automatic construction of the dialog tree based on unmarked text corpora in Russian
- Professional orientation: modern view and prospects of change
- Methods of development of andragogical competence of teachers
- Meta-feature selection method based on the Auto-sklearn framework
Last modified: 2021-10-21 20:01:11