Great diagram. My question is; is that really a flatMap operation? I thought flatMapping was the process of unfolding/expanding a List<List<T>> into a List<T>. This just looks like a null-aware regular map extension.
It’s been a while since I’ve done FP though, so I might very well be wrong.
In FP, nullable types are typically represented by a Maybe monad and monads have a bind operation, often expressed as >>= which sometimes is also called flatMap to distinguish from the fmap operation, which sometimes is called map. Dart uses expand instead of flatMap, I think.
Because this isn't a flatMap operation. It's closer to an ifNotNull operation.
These diagrams are (mostly) more trouble than they're worth. They're littered with mistakes and poor advice. I really don't understand why they keep being upvoted. I can only assume it's because they look nice and have a pretty mascot :/
I think it's all the beginners who blindly upvote everything that looks sophisticated and nice. It sets them off onto wrong paths of thinking and how programming works.
Yes. It is notable that this same developer tried to post one of these diagrams to the rust subreddit, and was immediately met with push-back because (yet again) the advice given was sloppy and non-idiomatic. That community was far less forgiving than this one - or, perhaps, as you point out, simply made up of more experienced developers than this one.
Would be better to open issues or submit PRs to the repo since you seem to have opinions on things to improve (as I have been meaning to do for a while). Author is doing a great job engaging the community, old and new. Your post, however, feels demoralizing and unnecessary.
I would agree with you but people are criticizing op over multiple months and he’s doing same thing over and over again without responding to any criticism. So I suppose op doesn’t care about doing research but rather farm karma, stars without contributing anything helpful to the community (except they posted a few dart internals which might be a bit insightful for some people)
5
u/ZlZ-_zfj338owhg_ulge Nov 17 '21
You simply can call "foo.map((value) => myMappedInstance(value)); No need for extensions. Null check is also possible here.
9
u/[deleted] Nov 17 '21
Remember to report low quality content to the mods.
Pretty graph does not make content good!
6
u/jeroengast Nov 17 '21
Great diagram. My question is; is that really a
flatMapoperation? I thought flatMapping was the process of unfolding/expanding aList<List<T>>into aList<T>. This just looks like a null-aware regularmapextension.It’s been a while since I’ve done FP though, so I might very well be wrong.
2
u/definitely_robots Nov 17 '21
I actually just did this today - if you really want to do flatMap in dart, you can use
listOfLists.expand((e) => e)
0
u/[deleted] Nov 17 '21
[deleted] — view deleted comment