| ▲ | i2talics 6 hours ago |
| I've long suspected that one of the things that makes monads notoriously difficult to explain to people outside of the Haskell ecosystem is that very few other languages even have a kind system that you are allowed to manipulate in code (and in some, like C++, it's so esoteric that you basically never see it). First explaining that you can even abstract over "type->type" kinded things gets you a lot of the way towards monads without actually describing monads. |
|
| ▲ | senshan 2 hours ago | parent | next [-] |
| The problem is not monads. Any programmer understands the need to represent "the world". It is the need to keep that representation modular that leads to monad transformers, which makes regular people (like me) simply check out and go back to C++ https://en.wikipedia.org/wiki/Monad_transformer |
|
| ▲ | taolson 5 hours ago | parent | prev | next [-] |
| That may be true for functions which operate on a generic Monad typeclass, but typeclasses (Higher kinded types) aren't required to implement concrete Functor / Applicative / Monad instances for a particular type, e.g. Maybe: fmap f Nothing = Nothing
fmap f (Just x) = Just (f x)
pure x = Just x
Nothing >>= f = Nothing
Just x >>= f = f x
|
| |
| ▲ | fn-mote 4 hours ago | parent [-] | | When people say they don’t understand Monad, my first assumption is that they are wearing their ignorance as a badge of honor. Otherwise memorize a little bit and dispose of the mystery. It’s not that far out. |
|
|
| ▲ | caaqil 5 hours ago | parent | prev | next [-] |
| > things that makes monads notoriously difficult to explain to people outside of the Haskell ecosystem Huh, I thought a monad is just a monoid in the category of endofunctors, what's the problem? |
| |
| ▲ | girvo 5 hours ago | parent [-] | | And here I was convinced that they’re burritos! I will say that explaining functors to my coworkers was always much simpler, and then naturally led to monads | | |
| ▲ | hexasquid 3 hours ago | parent [-] | | I suspect all branches of tech have their rite of passage. For haskellers, it is writing a monad tutorial For javascripters, it is writing a framework For make-stuff-with-LLM people, it is producing a diagram explaining your code generation factory ... and so on |
|
|
|
| ▲ | rramadass 5 hours ago | parent | prev | next [-] |
| Some OO languages have a parallel concept in "Metaclass" (https://en.wikipedia.org/wiki/Metaclass) i.e. the class of a class which is structurally similar to "Kind" though of course the mechanics are quite different. I still have an old book Putting Metaclasses to Work - A New Dimension in Object-Oriented Programming by Forman et.al somewhere. There is also the classic The Art of the Metaobject Protocol by Kiczales et.al which is quie relevant here - https://en.wikipedia.org/wiki/The_Art_of_the_Metaobject_Prot... The key difference is that the Type guys do it at compile time (correctness) while the OO guys do it at runtime (flexibility). |
|
| ▲ | epolanski 5 hours ago | parent | prev | next [-] |
| The thing that makes monads difficult is laziness and the anti math circle jerk. You start from a functor which is a data type that admits a map operation. Then you add of, or pure, to make an applicative functor, and then you add flatmap to make a monad. |
| |
| ▲ | windward 4 hours ago | parent | next [-] | | It's odd, the stereotype of software developers is a know-it-all attitude, but start talking about types and you get excuses that boil down to 'I'm incapable of learning to understand the thing you learned to understand'. | |
| ▲ | deterministic an hour ago | parent | prev | next [-] | | I used to be a big Haskell fan and had a lot of fun writing and using monads. And I agree that once you get them, the basic idea is quite simple. I’ve even used monads to prove a small compiler correct in Lean. But in practice, I think monads are a poor tool for large-scale software development. I spent a long time trying to build a large game in Haskell and eventually gave up out of frustration with the complexity they introduced. Monads make sense as a way to manage effects in pure languages like Haskell/Lean/Idris/Agda. But outside that context, I don’t think the additional abstraction is worth the cost. Understanding how monads work is one thing. Understanding why they’re needed in the first place, and when they’re not, is another. | | |
| ▲ | djtango 42 minutes ago | parent [-] | | OCaml isn't pure and neither is F# iirc do you see a bit less monad heavy code in large codebases there? What sort of situations would you want to give up a little purity or error handling at the type level? Maybe at a boundary where you can just write a very ugly imperative but quarantined section to give it a simpler type? |
| |
| ▲ | LoganDark 5 hours ago | parent | prev [-] | | > The thing that makes monads difficult is laziness and the anti math circle jerk. That's quite a hateful way to describe lack of knowledge. There are some prerequisites that make it easier to understand monads, and a lot of programmers don't even know those. That can make learning monads difficult right off the bat. | | |
| ▲ | epolanski 5 hours ago | parent | next [-] | | No there's no complexity behind monads except laziness and anti math circle jerk. It's really basic concepts, much easier than the analysis you do in high school. But people would rather sit through monad as boxes or burritos cringe tutorials. | | |
| ▲ | xboxnolifes 5 hours ago | parent | next [-] | | Your math explanation starts with a math concept that the vast, vast, vast majority of people will have never even heard of, even in math-adjacent fields. It's not anti-math reasoning. It's a lack of self-awareness that your background is very math heavy, which makes that particular explanation make sense to you. I've gone my entire schooling, as a student who was always one of the few who were "good at math", all the the way through my CS education, without ever having heard of a functor until I came across the Haskell monad explanation meme. Your next step could be to blame the school systems if you want, but that doesn't help the situation at hand. | | |
| ▲ | a57721 30 minutes ago | parent | next [-] | | I majored in mathematics and I learned category theory before touching any serious Haskell, and I still found most of the "monad tutorials" kind of opaque and handwavy, and I think there are inherently non-trivial details unrelated to the notion of functor etc. | |
| ▲ | fn-mote 3 hours ago | parent | prev [-] | | >> You start from a functor which is a data type that admits a map operation.
Then you add of, or pure, to make an applicative functor, and then you add flatmap to make a monad. > Your math explanation starts with a math concept that the vast, vast, vast majority of people will have never even heard of, even in math-adjacent fields Let me take this apart. 1. a data type that admits a map operation Present in most languages including JavaScript. Not a mathematical issue. 2. add of, or pure, to make an applicative functor I had to look this up. It was new content for me, maybe 5 or 10 minutes believing I would get it. 3. add flatmap This didn’t scare me but maybe it scares others. Not a mathematical issue here, though. Being in C++ doesn’t make this concept mainstream, I guess? https://en.cppreference.com/cpp/container/flat_map |
| |
| ▲ | LoganDark 2 hours ago | parent | prev | next [-] | | FWIW I dropped out of high school to pursue programming more directly. I regret it now because of the job market crash, but it's also too late for me to go back. | |
| ▲ | 5 hours ago | parent | prev [-] | | [deleted] |
| |
| ▲ | epgui 4 hours ago | parent | prev [-] | | Lack of knowledge is not the problem at all. Anti-intellectualism is. | | |
| ▲ | LoganDark 4 hours ago | parent [-] | | You can try to blame lack of knowledge on anything you want, but at the end of the day Hacker News is for intellectual curiosity and even HN readers don't all know what monads are. |
|
|
|
|
| ▲ | deterministic an hour ago | parent | prev [-] |
| [dead] |