TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Monads in pictures

98 pointsby chrisloalmost 13 years ago

7 comments

tikhonjalmost 13 years ago
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 未加载
vytisalmost 13 years ago
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>
kristopolousalmost 13 years ago
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 未加载
Lewtonalmost 13 years ago
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
jfaucettalmost 13 years ago
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 未加载
olhalmost 13 years ago
Can someone point me more resources for category theory in the computer science point of view?
bestestalmost 13 years ago
Someone's not ready for the HN-Effect? Website not responding.