[英]How to combine a comonad and a monad into a comonad?
Assume I have假设我有
D
D
T
T
l: DT -> TD
of the comonad D
over the monad T
.l: DT -> TD
是 comonad D
在 monad T
上的。 How can I define the comonad DT
?如何定义 comonad
DT
?
You can't.你不能。 Suppose
D
is the identity comonad and T
is Cont Void
, ie the continuation monad at the empty type.假设
D
是 identity comonad, T
是Cont Void
,即空类型的延续 monad。
newtype D a = D {runD :: a}
newtype T a = T {runT :: (a -> Void) -> Void}
Then distributivity holds trivially.那么分配性是微不足道的。 But
extract:: D (T a) -> a
is not definable as a total computable program.但是
extract:: D (T a) -> a
不能定义为一个完整的可计算程序。 It would be double negation elimination forall a. ((a -> Void) -> Void) -> a
这将是对
forall a. ((a -> Void) -> Void) -> a
forall a. ((a -> Void) -> Void) -> a
, which is not definable in constructive languages. forall a. ((a -> Void) -> Void) -> a
,这在构造性语言中是不可定义的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.