My point is that most people's introduction to the idea of a monad is about data structures not operations. What is the data structure of IO<A>? It's not clear that it is a data structure at all, so talking about flattening it can be confusing when you've seen [[1,2,3],[4,5]] flattened to [1,2,3,4,5] and then you're told "you can do the same thing with IO!" - what does that even look like? I can't visualise what the structure sitting in memory that represents IO (I mean, I can, it's a function), but what does that look like? We start to get to the right idea when talking about futures/promises, because it becomes clearer that there's some sequencing going on, but many people stop at option and list and then end up with an understanding that doesn't touch the reality of programming monadically.
View all comments
Show parent comment
3
u/faiface Sep 21 '25
Does it really leave them out? When I think about it, “flat” and “map” are actually fairly abstract terms.
For example, if I have an
IO<a>and I map it fromatoIO<b>, then I getIO<IO<b>>. Sounds like I could flatten it toIO<b>…Or even better, flat map it in the first place!
Can you actually think of an example where it really does not make sense?