gpt4 book ai didi

haskell - Haskell 程序可以类似于相互传递消息的对象吗?

转载 作者:行者123 更新时间:2023-12-04 20:33:38 26 4
gpt4 key购买 nike

关闭。这个问题需要更多 focused .它目前不接受答案。












想改进这个问题?更新问题,使其仅关注一个问题 editing this post .

5年前关闭。




Improve this question




Haskell 是一种纯粹的函数式语言,它打破了传统的面向对象语言。但是,请考虑 Alan Kay 关于 OOP 的“真正”含义的以下引用:

OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I’m not aware of them. -- Alan Kay



后来:

I thought of objects being like biological cells and/or individual computers on a network, only able to communicate with messages (so messaging came at the very beginning -- it took a while to see how to do messaging in a programming language efficiently enough to be useful).



我很好奇这种编程风格可以在 Haskell 中实现到什么程度。特别是,是否可以将 Haskell 程序构造为一系列(类似的)封装对象 来回传递消息 ?

注意:我正在寻找特定于 Haskell 的示例,而不是一般的功能语言(冲突时)。

最佳答案

only messaging, local retention and protection and hiding of state-process

like biological cells and/or individual computers on a network, only able to communicate with messages



我相信某些 Haskell 编程模式在某种程度上确实类似于 Kay 的描述。

在流媒体库中,如 conduit , pipesstreaming ,通常将计算构建为由不同阶段组成的管道。管道的每个部分都完全独立于其他部分,并且可以维护自己的私有(private)状态(您也可以在管道中拥有“共享”状态)。

拓扑往往是线性和单向的。也就是说,像管道的 ZipSink 这样的抽象——还有 Applicative Fold 的实例在 foldl包——让您构建分支的“树状”拓扑。和管道可以 bidirectional ,虽然我没有看到很多使用它的例子。

然后是 arrowized functional reactive programming .它可以让你建立自动机箭头的“电路” can even include loops .电路的每个部分都可以保持自己的状态。正如 netwire 的描述FRP 库状态:

This library provides interfaces for and implements wire arrows useful both for functional reactive programming (FRP) and locally stateful programming (LSP).



来自 auto 的文档图书馆:

auto works by providing a type that encapsulates value stream transformers, or locally stateful functions; by specifying your program as a (potentially cyclic) graph of relationships between value streams, you create a way of declaring a system based simply on static relationships between quantities.

Instead of a state monad type solution, where all functions have access to a rigid global state, auto works by specifying relationships which each exist independently and on their own, without any global state.

关于haskell - Haskell 程序可以类似于相互传递消息的对象吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40330481/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com