Computer Engineering and Applications ›› 2012, Vol. 48 ›› Issue (28): 71-76.

Previous Articles     Next Articles

Research and realization of generic identity based on functional language

LI Yang, YU Shangchao, WANG Peng   

  1. Dept. of Computer, Institute of Command Automation, PLA University of Technology & Science, Nanjing 210007, China
  • Online:2012-10-01 Published:2012-09-29

函数式语言泛型特性的研究与实现

李  阳,于尚超,王  朋   

  1. 解放军理工大学 指挥自动化学院计算机系,南京 210007

Abstract: Parametric polymorphism is crucial to generic programming in that it adopts parameterized types and therefore fully supports the abstraction on types and increases the level of software reuse. For the moment, the idea of generic programming has been realized in many languages, which have got great achievement. Haskell is a popular language, and it is functional too. It has a lot of advantages, such as, simple module, clarity syntax, etc. So the programmer can write and modify Haskell sentence easily. This thesis shows the extension of the grammar of Haskell according to some rules, which also introduces the idea of generic programming, and gives some methods to define generic functions. Finally, the function of generic would be completed in Haskell.

Key words: generic programming, type abstract, functional programming, grammar extension

摘要: 对于泛型程序设计来说,类型的参数化多态是其理论框架,参数化多态引入了类型变量,使得类型参数化,支持类型上的抽象,从而可以大大提高软件的复用程度。泛型编程思想已经在多种语言中得到运用,并已取得了不小的成果。在函数式语言上进行泛型的研究与应用,Haskell语言是函数式语言中较为经典的一种语言,它的计算模型简单,语法清晰,易于编写,易于维护,拥有很大的发展空间。利用一些规则对Haskell语言的语法进行相关扩展,同时引入泛型的思想,研究与运用定义泛型函数的方法,在Haskell语言上实现了泛型功能。

关键词: 泛型编程, 类型抽象, 函数式程序设计, 语法扩展