I actually kind of disagree. map(f).getOrElse(y) clearly conveys the intent of your code and makes it easy to understand for other people. fold(y)(f) doesn't. In my case at least, I always have to do the mental gymnastic of "oh, this means map.getOrElse"
-
This Tweet is unavailable.
-
-
This Tweet is unavailable.
-
Replying to @propensive
Honest question though: is that a proper fold? In my mind, fold is heavily linked to monoids: - takes an "empty" value - takes a merge function that's basically a monoidal append This is not what Option.fold does. Am I misunderstanding what fold is?
2 replies 0 retweets 2 likes -
Replying to @NicolasRinaudo @propensive
Your mixing `Foldable` (the typeclass) with the algebraic fold, the later is basically isomorphic to pattern matching. The fact that folding on a List is recursive, is incidental (because the type itself is recursive), not the opposite.
2 replies 1 retweet 14 likes -
Replying to @aloiscochard @propensive
Ah. So then, on the one hand it makes sense, on the other, I feel it might be a fact in favour of my argument: it might be unreasonable (today) to expect most developers to know about algebraic folds, and map(x).getOrElse(y) *will* be more readable for the majority of them
3 replies 0 retweets 1 like -
Why is it unreasonable to expect developers to know the basics of their profession? Is it also unreasonable to expect pilots to not know where the throttle is located?
1 reply 0 retweets 5 likes -
This Tweet is unavailable.
-
Replying to @propensive @dibblego and
Flying is easy but unforgiving of errors. It gives meaning to “fatal error”.
1 reply 0 retweets 0 likes
I can think of lots of (literal) fatal errors in software. Even those that apply to flying. Indeed, it's a contributor to why I often turn off the "(broken) certificated avionics" when I fly.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.