6 ms·
Monad Tutorials Timeline
- gnabgib 6mo agoIt's an updating wiki.. but (2017) https://news.ycombinator.com/item?id=15170328 https://news.ycombinator.com/item?id=15170328 Popular well.. submissions in: 2019 (3 points) https://news.ycombinator.com/item?id=19207241 https://news.ycombinator.com/item?id=19207241 2022 (3 points) https://news.ycombinator.com/item?id=30277518 https://news.ycombinator.com/item?id=30277518 2024 (11 points) https://news.ycombinator.com/item?id=40332349 https://news.ycombinator.com/item?id=40332349
- deleted 6mo ago[deleted]
- cpa 6mo agoPretty cool! I've spent a lot of time wrapping my head around monads; whenever I thought I "got it," I would come across some exotic monad that completely blew my mind. The best way to understand them is not to rely on analogies but just follow the rules—everybody says that, but it took me a while to truly realize it. See, for example, the Tardis monad or the Cont monad: https://www.reddit.com/r/haskell/comments/446d13/exotic_monads/ https://www.reddit.com/r/haskell/comments/446d13/exotic_mona...
- ducklord 6mo agoI tried understanding the rules but actually using it helped me to get it. Especially when I was using a parser combinator to parse a programming language.
- Dig1t 6mo agoSo weird, on the front page at the same time as this: "Biology is a burrito" When I saw that link it immediately reminded me of this: https://blog.plover.com/prog/burritos.html https://blog.plover.com/prog/burritos.html >Monads are like burritos And then a few links down is this link to monad tutorials. Weird coincidence.
- preommr 6mo agoTo explain like two fundamental rules (we can make wrapper types, and do flatmap) I will: - Write 5 paragraphs setting up an imaginary scenario involving fantasy elements of aliens, dragons, and a magical kindom where they speak using message boxes - Introduce basic category theory by starting with what a functor is - Explain all the effects of a monad in such general terms that it basically amounts to anything and everything - since a function can be anything and do everything and it's just function composition - Write some snippets of Haskell, and just assume that you're familiar with the syntax - Talk about how delicious burritos are
- alper 6mo agoI've read more than my fair share of these tutorials, and I'd like to be proven wrong here but I don't think I've ever seen one that explains what the point of these functional constructs (similarly with Applicative etc.) is. "You can do IO now." So what? I could do IO before that as well. Very rarely are practical explanations discussed. Even if they are discussed, the treatment is shallow and useless.
- lmm 6mo agoHere's my effort: https://m50d.github.io/2013/01/16/generic-contexts https://m50d.github.io/2013/01/16/generic-contexts
- amenghra 6mo agoFrom the very beginning of the article (level 1), I don't see what's wrong with code that looks like the following. Early return seems to fix the "typing this makes me feel ill" part? To me, the following code seems perfectly readable without requiring the reader to know about function composition. def doFunctionsInSequence1(): Option[Set[Int]] = { val r1 = f1(null) if(r1.isEmpty) { return None } val r2 = f2(r1.get) if(r2.isEmpty) { return None } return f3(r2.get) }
- lmm 6mo ago
- cubefox 6mo agoI understood the monad concept for a few months in university. After the exam was over, I soon stopped understanding it. The same thing happened with the concept of VC dimension. It's kind of interesting, because we usually don't think of "understanding" as something that comes with a time limit.
- alper 6mo agoIt happens all the time. For a brief period I understood musical notation and rhythm and then it was gone. Similarly I had a time in my life where I knew by feeling whether a French noun was le or la.
- cubefox 6mo agoThe sneaky thing here is that understanding, and knowledge in general, disappear silently. So you don't notice it when you unlearn and forget something. Only if a situation comes up where you need that understanding again do you notice that it is gone. Coming to understand something is conscious, losing that understanding is unconscious.
- armchairhacker 6mo agoI still don’t understand why it’s named from Gnosticism (https://en.wikipedia.org/wiki/Monad_(Gnosticism) https://en.wikipedia.org/wiki/Monad_(Gnosticism))
- urxvtcd 6mo agoYeah, would like to know as well. I think the applicative functor was originally call "Idiom", another weird name.
- deleted 6mo ago[deleted]
- yccs27 6mo agoMonads got their name from monoids (being a monoid in the category of endofunctors). Monoids are equivalent to one-object categories, so the name uses the greek syllable "mono" for one.
- intrinsicallee 6mo agoIt comes from Pythagoras, not Gnosticism
- ReptileMan 6mo agoI have always thought that monads are just side effects and that's it.
- hocuspocus 6mo agoMost monadic effects aren't executing side effects.
- lmm 6mo agoOn the contrary, every monadic effect is a side effect. It's just that what exactly that means is specific to the monad in question.
- chuckadams 6mo agoMonads are popular for side effects because they have an implicit notion of sequencing, so evaluating a monadic expression enforces the sequence of operations. Works out nice for IO and Futures and so on. But List is also a monad, and flatMap (as many other languages call it) doesn't inherently have any side effects at all. Same goes for Maybe/Option (essentially a list of zero or one element), and State (which does take advantage of sequencing). It's all about getting an intuition for how many things fit the shape: flatMap :: m a -> (a -> m b) -> m b Where "flatMap" might have different names in different types. Once you see that pattern in some code, you'll start seeing it in a lot of other places.
- bazoom42 6mo agoNope. For example lists are monads, but doesn’t have anything to do with side-effects. Monads are just a pattern for chaining functions.
- FrustratedMonky 6mo agoA good explanation I read once. That the best way to understand Monads, was to write a Tutorial about Monads. Which does make sense. To understand a subject, the best way is to teach the subject.
- drgiggles 6mo agoWeird timing, I just stumbled upon this Brian Beckman video recently https://youtu.be/ZhuHCtR3xq8?si=ifeR6wddsPRdOw1N https://youtu.be/ZhuHCtR3xq8?si=ifeR6wddsPRdOw1N
- LukeHoersten 6mo ago2015 was the best for Haskell. Definitely had a bit of a moment.
- petesergeant 6mo agoIt took me a long time to write an explainer on embeddings, and one day I will finally finish my Monad tutorial. I think fundamentally you need to have needed them to solve a problem to get them, and outside of pure languages you have to do a lot of special-condition setup to explain why you need them. "You Could Have Invented Monads"[0] is probably my favourite existing one. 0: https://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html https://blog.sigfpe.com/2006/08/you-could-have-invented-mona...
- bedobi 6mo agoHere’s my monad tutorial for programmers A monad is anything you can flatmap with The monad of list is you flatmap a list on a list and instead of getting a list of lists, as you would if you just mapped, you get a single flattened list The monad of Result is you flatmap many function calls (like http requests or whatever) on each other and instead of getting many results, you get a single flattened result Most of you already know this, without necessarily even knowing what a Monad is Monad literally just means "one thing" - you take many things, and flatmap them into one Thanks for attending my ted talk
- throw_await 6mo agoAnd by introducing Monad, we gain the ability to abstract over these things: List, Option, Result, Functions, State, ...
- bedobi 6mo agoyes, which is why Monad should be an interface that types like List, Option, Result etc implement, instead of flatMap being just a random discrete function that exists on random types by accident, with no common abstract link between them Kotlin, Java, basically every other language except Haskell, F# etc didn't get that memo
- deleted 6mo ago[deleted]
- 12_throw_away 6mo agoHonestly, it seems like the common denominator for all this confusion is Haskell, and specifically its IO system, not the monad interface itself. E.g., lots of languages have something like an "Iterable" interface, which - while it may be non-trivial for beginners to learn - absolutely does not require tortured metaphors to explain it. No one has ever needed burritos to explain Result::and_then [1]. [1] https://doc.rust-lang.org/std/result/enum.Result.html#method.and_then https://doc.rust-lang.org/std/result/enum.Result.html#method...
- jnpnj 6mo agoVery very nice timeline ! some interesting papers from the 90s section. Maybe they could add https://github.com/VincentToups/emacs-utils/blob/master/monads.md https://github.com/VincentToups/emacs-utils/blob/master/mona... . I found J.V. Toups writing very nice, and useful to see how monadic composition could exist without type support.
- epogrebnyak 6mo agoSome tutorials seem to predate introduction of monad itself, it seemed... )
- jnpnj 6mo agoWell, Moggi's paper on monads is from 91 and wadler first tutorial from 92. Am I missing something ?
- bazoom42 6mo ago[dead]