首页 | 本学科首页   官方微博 | 高级检索  
相似文献
 共查询到17条相似文献,搜索用时 125 毫秒
1.
Monad作为构造纯函数式语言的工具,能构造出诸如错误处理、状态、I/O等非纯函数式语言的特征.本文通过组合状态转换Monad和异常处理Monad来定义纯函数式LazyI/O操作,既保持了纯函数式语言的特征,又融入了非纯函数式语言的特征.  相似文献   

2.
状态、输入和输出是Z规范的基础,引入Monad的纯函数式语言特别适合用来实现用Z规范说明的系统.通过将状态、输入和输出封装在一个Monad内,提出一种基于Z规范的纯函数式程序设计方法.  相似文献   

3.
吕江花  金成植 《软件学报》2003,14(12):1989-1995
Monad程序的核心是一组Monad定义.Monad定义分为MAP型和BIND型.如果在Monad库中已有所需要的Monad定义型,则可以直接使用,而不需要重新构造;否则,需要重新构造.但如果在Monad程序设计环境中增加从一类Monad构造另一类Monad的自动生成器,那么既方便了用户也扩充了1倍原有的Monad库.鉴于这种思想,用支持Monad程序设计的高阶函数语言Haskell实现了一个Monad的自动生成系统.另外,用户构造Monad不仅要花费较多的时间,而且写出的Monad多态函数往往不满足Monad所需满足的几条公理,因此,从这方面也可以看出,从一种类型的Monad自动产生另一种类型的Monad的重要意义.  相似文献   

4.
采用一种基于范畴论发展出来的Monad的实现方法,该方法可从编译器中提取操作性语义,然后将其等价转换为指示性语义。由于Monad方法普遍适用于函数式编程语言,使得基于Monad的可认证数据结构可根据源语言的语法生成新语言特性。优点是新语言特性的设计者无须深入了解修改编译器语法树,也无须修改源语言的语法,即可完成程序语言编译器之间语义的移植。  相似文献   

5.
本文通过状态转换器来定义I/O的文件系统,并用非确定性Monad描述了操作系统的进程同,从而给出了通道系统的语义。  相似文献   

6.
采用unboxed数据类型实现纯函数式I/O系统,通过一个由unboxed数据类型定义的程序转换系统将纯函数式I/O程序转换为C语言代码,其中着重讨论了基本操作ccall的实现.  相似文献   

7.
函数式语言中的赋值语句   总被引:7,自引:0,他引:7  
文章探讨了怎样在纯函数式语言中加入赋值操作,而又不丧失引用透明性特征的问题,给出了这些操作的指称语义,并用这些赋值操作定义了一个简单的命令式语言的解释程序.  相似文献   

8.
袁华强  孙永强 《软件学报》1996,7(11):683-690
PhilipWadler在探讨用Monad构造纯函数式程序时,介绍了一个简单的词法分析程序的构造过程.本文进一步研究了这种方法,并用这种方法构造出一个能进行复杂的layout分析、词法分析与语法分析的纯函数式分析程序.  相似文献   

9.
袁华强  孙永强 《软件学报》1997,8(A00):189-193
纯函数式语言缺乏处理非确定性功能,本文给出了一个非确定性Monad,用此Monad在纯函数式语言中加入了非确定性处理功能,描述卫个基于非确定性Monad的纯函数式树搜索算法,并证明了一些有用的代数性质。  相似文献   

10.
使用函数式语言书写的程序包含了稳式的并行性。由于表达式可以以任意次序计值,因此无需显式的并行结构来管理并行性,且可以非常方便地在并行计算机体系结构上实现,程序正确性的证明也相对简单。但一般说来在函数式语言并行实现过程中所开发的是细颗粒度的并行性,它的管理开销较大。本文在纯函数式语言Miranda中引入两个并行进程构造子,它们的使用使得在粗颗粒度上管理并发进程的产生、执行、通讯、同步成为可能,从而提高了程序的执行效率。  相似文献   

11.
Dataflow models are free of side effects and have no notion of state or sequencing. Because these representations place a partial, as opposed to a total, ordering on the execution of their component operations, the concurrent aspects of computation are clearly revealed. The correspondence between dataflow graphs and purely functional programs allows computations to be expressed in a high-level functional language and subsequently transformed into a dataflow graph. This paper describes the use of dataflow models as an alternative control strategy for engineering analysis programs and contrasts them with traditional imperative approaches. The characteristics of functional languages are also described, as is their inherent parallelism, which may be realized by compilation into dataflow graphs. The application of functional languages to finite element programming is presented, which allows the alternating assembly and solution of system equations found in frontal solvers. Issues such as the incremental update of arrays and the simulation of state are also addressed.  相似文献   

12.
State in Haskell     
Some algorithms make critical internal use of updatable state, even though their external specification is purely functional. Based on earlier work on monads, we present a way of securely encapsulating stateful computations that manipulate multiple, named, mutable objects, in the context of a non-strict, purely-functional language. The security of the encapsulation is assured by the type system, using parametricity. The same framework is also used to handle input/output operations (state changes on the external world) and calls to C.  相似文献   

13.
State in Haskell     
Some algorithms make critical internal use of updatable state, even though their external specification is purely functional. Based on earlier work on monads, we present a way of securely encapsulating stateful computations that manipulate multiple, named, mutable objects, in the context of a non-strict, purely-functional language. The security of the encapsulation is assured by the type system, using parametricity. The same framework is also used to handle input/output operations (state changes on the external world) and calls to C.  相似文献   

14.
This paper describes LPS, a Language Prototyping System that facilitates the modular development of interpreters from semantic building blocks. The system is based on the integration of ideas from Modular Monadic Semantics and Generic Programming.To define a new programming language, the abstract syntax is described as the fixpoint of non-recursive pattern functors. For each functor an algebra is defined whose carrier is the computational monad obtained from the application of several monad transformers to a base monad. The interpreter is automatically generated by a catamorphism or, in some special cases, a monadic catamorphism.The system has been implemented as a domain-specific language embedded in Haskell and we have also implemented an interactive framework for language testing.  相似文献   

15.
A Boolean category is a restriction category if and only if it has one exception and all morphisms are deterministic. In the category of sets, taut monads are precisely the Boolean ones. It follows that collection monad types in Haskell inherit an assertion calculus based on dynamic logic.  相似文献   

16.
17.
A pipeline is a popular architecture which connects computational components (filters) through connectors (pipes) so that computations are performed in a stream like fashion. The data are transported through the pipes between filters, gradually transforming inputs to outputs. This kind of stream processing has been made popular through UNIX pipes that serially connect independent components for performing a sequence of tasks. We show in this paper how to formalize this architecture in terms of monads, hereby including relational specifications as special cases. The system is given through a directed acyclic graph the nodes of which carry the computational structure by being labelled with morphisms from the monad, and the edges provide the data for these operations. It is shown how fundamental compositional operations like combining pipes and filters, and refining a system by replacing simple parts through more elaborate ones, are supported through this construction.Received: 23 September 2002 / 4 May 2003  相似文献   

设为首页 | 免责声明 | 关于勤云 | 加入收藏

Copyright©北京勤云科技发展有限公司  京ICP备09084417号