Computer Engineering and Applications ›› 2018, Vol. 54 ›› Issue (7): 1-10.DOI: 10.3778/j.issn.1002-8331.1710-0159

Previous Articles     Next Articles

Meta-modeling method for implementing template meta-programming of functional programming

ZHU Yi1,2, HUANG Zhiqiu1, ZHOU Hang1, LIU Linyuan1,3   

  1. 1.College of Computer Science and Technology, Nanjing University of Aeronautics and Astronautics, Nanjing 210016, China
    2.School of Computer Science and Technology, Jiangsu Normal University, Xuzhou, Jiangsu 221116, China
    3.School of Economics and Trade, Nanjing Audit University, Nanjing 211815, China
  • Online:2018-04-01 Published:2018-04-16

函数式程序模板元编程的元建模实现方法

祝  义1,2,黄志球1,周  航1,刘林源1,3   

  1. 1.南京航空航天大学 计算机科学与技术学院,南京 210016
    2.江苏师范大学 计算机科学与技术学院,江苏 徐州 221116
    3.南京审计大学 经济与贸易学院,南京 211815

Abstract: In order to solve the problem that the template meta-program of functional programming language lacks generality, this paper proposes a meta-modeling method for implementing the template meta-programming of functional programming, which is illustrated by the case of Applied Type System(ATS). Firstly, an instance for generating code from Datatype to Function is given based on ATS template meta-programming. Secondly, an ATS meta-model which includes the definitions of Datatype and Function is constructed by meta-modeling. Thirdly, the transformation from Datatype model to Function model is described. Lastly, an example of ATS template meta-programming based on meta-modeling is given to verify the effectiveness of this method. The experiments show that the method can increase the generality of ATS template meta-programming.

Key words: functional programming, Applied Type System(ATS), template, meta-programming, model transformation

摘要: 针对函数式程序模板元编程的通用性问题,以应用类型系统ATS(Applied Type System)为例,提出了一种基于元建模的模板元编程实现方法。基于ATS模板元编程给出从枚举类型Datatype到Function的生成实例;通过元建模构造了包含Datatype与Function定义的ATS元模型;详细描述了Datatype模型到Function模型的转换;最后以一个基于元建模的ATS模板元编程为例,讨论了该方法的使用效果。实验结果表明该方法可以提高ATS模板元编程的通用性。

关键词: 函数式程序, 应用类型系统, 模板, 元编程, 模型转换