【发布时间】:2016-07-21 02:18:34
【问题描述】:
看这个IO代码:
Prelude> let e = return () :: IO ()
Prelude> e `mappend` e
Prelude> let y = e `mappend` e
Prelude> :t y
y :: IO ()
编辑显然,据我了解,IO 有一个 Monoid 实例。
但是,为了遵守 Monoid 第三定律,下面的计算不应该为 true 吗?
Prelude> e `mappend` (e `mappend` e) == (e `mappend` e) `mappend` e
<interactive>:14:1: error:
* No instance for (Eq (IO ())) arising from a use of `=='
* In the expression:
e `mappend` (e `mappend` e) == (e `mappend` e) `mappend` e
In an equation for `it':
it = e `mappend` (e `mappend` e) == (e `mappend` e) `mappend` e
【问题讨论】:
标签: haskell