ComputingComputer ScienceCompilersData StructuresProgramming LanguagesData TypesFunctional ProgrammingObject-oriented DesignObject-oriented ProgrammingSoftware ReuseType SystemsCode ReuseObject-oriented ArchitectureObject-oriented Language DesignPolymorphic CodePolymorphic TypesPolymorphism StudiesStatic PolymorphismType Polymorphism
Their support for code reuse has made object-oriented languages popular. However, they do not succeed equally in all areas, particularly when data has a complex structure, making hard to keep the parallel between data and code. On the other hand, functional programming languages, which separate data from code, are better at handling complex structures, but they do not provide direct ways to reuse code for a different datatype. We show here a way to achieve code reuse, even when data and code are separated. The method is illustrated by a detailed example. 1 Introduction Design of complex programs sometimes bump into a difficult dilemma: which should be privileged of type safety and code reuse. Maintaining complete type safety forces to specialize the code, making it difficult to reuse it in similar situations. Decrease in reuse may mean more difficult maintenance and tracing of logical bugs. On the other hand, trading safety for more reuse also means weaker help from the type s...