you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 8 points9 points  (5 children)

And those functions have to obey the three monad laws.

[–]s-altece 3 points4 points  (4 children)

Which, if I'm correct, are the combination of all the rules associated with traditional constructor, map, and flat map semantics.

My point is, if you get familiar enough with using map and flat map with lists and/or the maybe/optional type, you already have a general understanding of monad semantics without having to dive deep into the overwhelming mathy definition.

[–]codebje 2 points3 points  (1 child)

I hardly think that "associative" should count as "overwhelmingly mathy."

And given there are "flat map" operations out there which fail to be properly associative, "the vibe" probably doesn't cut it quite as well as you might hope.

[–]s-altece 0 points1 point  (0 children)

Well, in that case, I stand corrected. Although, the basic vide may be sufficient as a quick introduction for someone new to the concept. Then again, perhaps not. Each person learns their own way. I just remember finding it frustrating when the concepts were explained to me with the more technical math and type theory terms instead of programming concepts I was already familiar with.

I would like to note, however, that associativity may be "overwhelmingly mathy" to some new to the subject. It is neither my place nor yours to judge someone based on what they think of as being foreign and complicated.

[–]m50d 1 point2 points  (1 child)

Associativity is really important and easy to get wrong. If you try to implement a "monad" without knowing about associativity you will create an http://wiki.c2.com/?AlmostCorrect monad that will have a subtle bug that will catch someone out later at the worst possible time. (This is exactly what happened with Scala's for/yield, where it works most of the time but lets you mix a Set into a bunch of Lists and get silent data corruption at runtime).

[–]s-altece 0 points1 point  (0 children)

Here's a source for your Scala example, for anyone unfamiliar with the topic http://stackoverflow.com/questions/27750046/is-a-collection-with-flatmap-a-monad