【发布时间】:2016-03-28 03:37:17
【问题描述】:
在基于此article 的有关并发性的一般练习中。
我们有:
-- a is the result type on which after we continue
type Continuation a = a-> Action
type ContinuationPseudoMonad a = Continuation a -> Action
-- pseudoMonad because it will need Concurrent wrapper Monad:
-- so as to define bind operation and return operation on it
data Concurrent a = Concurrent (ContinuationPseudoMonad a)
所以Concurrent a 是一个monad,我们必须用它的两个强制性法则来实施,返回和绑定。
不幸的是,我找不到足够的词来更准确地定义 ContinuationPseudoMonad 的东西......如果我没有词,我的脑海中就缺乏抽象。
你会怎么称呼它?
有没有意思Continuation a -> Action而不是我尴尬无意义的ContinuationPseudoMonad?
动作是:
data Action = Atom (IO Action)
| Fork Action Action
| Stop
【问题讨论】:
-
您的问题是如何为
Concurrent定义return和>>=,就像您在上面定义的那样? -
另外,有点错别字 - 我想你的意思是,
data Concurrent a = Concurrent (ContinuationPseudoMonad a),因为data Concurrent a = Concurrent ContinuationPseudoMonad a是一个错误。 -
我根据您的陈述进行了相应的更正。问题是我没有成功地理解什么是`Continuation a -> Action'。这个抽象的名字会很棒。
-
我认为唯一的词是 'monad without its
newtypewrapper' (顺便说一下,newtype比dataforConcurrent更好,因为它不会在运行时添加额外的层表示Concurrent构造函数)或“连续传递式函数”。 -
我很佩服您对各个级别的描述性名称的渴望
标签: haskell abstraction