摘要
泛型即通过参数化类型来实现在同一份代码上操作多种数据类型。泛型编程是一种编程范式,它利用"参数化类型"将类型抽象化,实现灵活的软件复用。泛型编程思想已经在多种语言中得到运用,并已取得了不小的成果。文中旨在Haskell语言上进行泛型的研究与应用,Haskell语言是一门广为流行的函数式语言,它的计算模型简单,程序语法清晰,易于编写,易于维护。文中利用一些规则对Haskell语言的语法进行扩展,同时引入泛型编程的思想来研究新的函数定义方法,最后在Haskell语言上实现泛型功能。
Generic can treat the types as arguments. Then many kinds of data-types can be processed by the same source code. Generic programming is a normal form of programming. It can make types abstract by a method called type parameterization. So realize the goal of software reuse agilely. For the moment, the idea of generic programming has been realized in many languages, which have got great achievement. It is intended to make some research in the field of Haskell language, and give an application as an example. 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. It 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 functions. Finally, the function of generic would be completed in Haskell.
出处
《计算机技术与发展》
2012年第6期89-92,96,共5页
Computer Technology and Development
关键词
泛型编程
类型抽象
函数式程序语言
语法扩展
generic programming
type abstract
functional programming language
grammar extension