TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Haskell’s State monad is not a monad (2014)

103 点作者 setra将近 7 年前

5 条评论

lmm将近 7 年前
This isn&#x27;t about the state monad, it&#x27;s about seq. &quot;But now seq must distinguish ⊥ from λx → ⊥, so they cannot be equal. But they are eta-equivalent. We have lost eta equality!&quot; - once you lose eta equality you lose everything. A whole raft of monads become impossible, not just state.<p>Equivalence in Haskell is defined only up to ⊥; to work in Haskell we rely on the &quot;Fast and Loose Reasoning is Morally Correct&quot; result that <i>if</i> two expressions are equivalent-up-to-⊥. and both non-⊥ then they are equivalent.<p>(Or, y&#x27;know, work in Idris with --total and avoid this problem entirely).
评论 #17441551 未加载
评论 #17441760 未加载
评论 #17442221 未加载
carterschonwald将近 7 年前
This is all pretty fun reading.<p>At least with my own code in Haskell, I work in the mental model where I assume termination and strong normalization (all programs terminate under all evaluation strategies).<p>Then, Bottom corresponds to either an exception that will get forced or a computationally boring infinite loop (which the rts can sometime detect and turn into an exception). My personal style favors having those errors be very very visible.<p>That said, depending on what formal or informal reasoning properties you care about (especially as a library writer), these little subtleties can be really important!
评论 #17444194 未加载
danabrams将近 7 年前
The real monad was the friends we made along the way.
pacala将近 7 年前
Cute, but why should one care about ⊥, aka bottom, aka nontermination [0]? Let&#x27;s write programs that terminate...<p>[0] <a href="https:&#x2F;&#x2F;wiki.haskell.org&#x2F;Bottom" rel="nofollow">https:&#x2F;&#x2F;wiki.haskell.org&#x2F;Bottom</a>
评论 #17441451 未加载
评论 #17441867 未加载
评论 #17441709 未加载
评论 #17441271 未加载
dustingetz将近 7 年前
It seems to me a piece of software is either a formal proof or it&#x27;s not. So if it&#x27;s not and we still manage to write robust programs, the natural next question is, to what degree is it okay to knowingly violate the laws? And if you iterate that to the nth, do you end up with Clojure?
评论 #17441283 未加载