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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Monads in pictures

98 点作者 chrislo将近 13 年前

7 条评论

tikhonj将近 13 年前
That's not really how I visualize functors. Let's go back to the function picture:<p><pre><code> --- --- |a| -- f --&#62; |b| --- --- </code></pre> This is fairly simple--using f, you can go from a to b.<p>Now lets imagine a functor F (with f still being our function):<p><pre><code> --- --- |a| -- f --&#62; |b| --- --- | | |F| \ / V ---- ---- |a'| -- f' --&#62; |b'| ---- ---- </code></pre> So a functor is just a function at a higher level. A function maps values of one type to values of another type. A functor maps types to other types. In Haskell, types in the Functor class always map types of kind * back onto * , so they're much like functions of type a -&#62; a.<p>The crucial part to notice is that it not only maps between types but it also <i>preserves</i> functions. That is, you get new types corresponding to your old types and new functions corresponding to your old functions.<p>So the list type, for example, maps any type a to [a] and any function (a -&#62; b) to ([a] -&#62; [b]). In a sense, it is like a well-behaved function between types.<p>Coincidentally, thinking of functors like this is how I realized that functors in Haskell are <i>not</i> completely unrelated to functors in OCaml--they're just different reifications of the same mathematical idea.
评论 #4412428 未加载
评论 #4412122 未加载
评论 #4412035 未加载
评论 #4413497 未加载
vytis将近 13 年前
Site seems to be down, here's a cached copy: <a href="http://webcache.googleusercontent.com/search?hl=en&#38;client=safari&#38;rls=en&#38;sclient=psy-ab&#38;q=cache%3Anewartisans.com%2F2012%2F08%2Fmonads-in-pictures%2F&#38;oq=cache%3Anewartisans.com%2F2012%2F08%2Fmonads-in-pictures%2F&#38;gs_l=serp.3...60377.63295.1.66800.8.8.0.0.0.1.193.880.0j6.6.0.les%3Bernk_fspiked..0.2...1c.xvj46ZWKaRg&#38;pbx=1" rel="nofollow">http://webcache.googleusercontent.com/search?hl=en&#38;clien...</a>
kristopolous将近 13 年前
Decent article, but I have something a little off ... it's an honest question though:<p>What compels people to use words like "grok"? Is comprehend, digest, understand, follow, etc. so insufficient that it necessitates an ugly sounding word meaning emotional absorption to be misappropriated as mental absorption? There's no good tense rules established and it's not widely known outside the domain of nerdom. So I ask, to what ends?
评论 #4412468 未加载
评论 #4412298 未加载
评论 #4412315 未加载
Lewton将近 13 年前
I know nothing about Monads, I know nothing about Haskell except for the fact that it's a functional programming language that has Monads. Yet I still found this really informative... Makes me want to play around with Haskell and see if this article makes it easy to grok how Monads work
jfaucett将近 13 年前
from a non-Haskell programmer here. It looks like monads are just a way to call functions in difference context, in js<p><pre><code> map(myObj, someFunc, contextObj) </code></pre> Or am I missing something here?
评论 #4412166 未加载
评论 #4412423 未加载
评论 #4412282 未加载
评论 #4412164 未加载
评论 #4412569 未加载
olh将近 13 年前
Can someone point me more resources for category theory in the computer science point of view?
bestest将近 13 年前
Someone's not ready for the HN-Effect? Website not responding.