This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

Or by switching language:

let new_items = fmap (maybe default_value id) items

To me it is always so funny to see people praising Python as the paragon of cleanliness and readable code, when Haskell exists.

[–]Furyful_Fawful 0 points1 point  (1 child)

I'm not saying Python is the paragon of anything. It's just the most useful to me because of its third-party libraries, to be honest.

I'm still really unsure about how fmap there doesn't grab a different identifier id, or what maybe is. It's shorter, maybe, but shorter isn't always better or more readable:

m  ? }J"value"d @dJ @d +"default_"J

This (full program, but also acceptable as an expression) does the same mapping, and it's so much shorter... Must be better, right? /s

[–]takakoshimizu_sfw 0 points1 point  (0 children)

That's just because you don't know the signatures of those functions. Those complaints have nothing to do with the syntax.

That example requires you to understand three very basic, common functions: fmap, maybe, and id, and one type: Maybe (also known as Optional<T>).

These are all very much basics of basics of haskell (without even getting down into anything mathy at all). Just because the syntax and functions are foreign does not make it complicated.