2 ms·
> The parent is not defining a monad with that sentence, he is defining what a monadic function is given that you have something that behaves like a monad But
by StavrosK 12y ago
> The parent is not defining a monad with that sentence, he is defining what a monadic function is given that you have something that behaves like a monad
But I have no idea what a monad is, so it's all equivalent to "a blorx function is a function that returns a value in the blarx blorx". He never explained that a monad is different from a function, or that a monad is something that has values, or that you can return them, or any of the parts that make up that sentence.
> To learn about monads, you have to look at specific examples like the List monad, or the State monad or the IO monad. But there is no general explanation of a monad any more tangible than what the parent said.
I have a feeling that that's exactly what someone who attempts to explain what monads are should talk about. If they're a general concept, like patterns (the concept of patterns in general, not specific patterns), it is probably clearer to show how specific examples work and then how they relate to each other, so someone who doesn't know anything about them can grasp their significance.
- logicallee 12y agoYou're not seriously asking for a definition of a basic everyday English word like monad, are you? (hmmm, Chrome underlines this word in this edit box for some reason - probably some political thing since C++, Go, and Python - Google's go-to languages - don't support this extremely mundane and everyday feature.) Anyway it's like the word 'if' or 'except'. You just need to know about the syntax or any rules. Type "define monad" into Google if you don't know this super-basic word. (Personally, I would have thought most of us learned it when we were 3 or 4 and learning the numbers or the alphabet song). Anyway watch: http://google.com/search?q=define%20monad http://google.com/search?q=define%20monad it clearly tells you, >Monad: a single unit; the number one. What could be simpler? So we can simply understand the OP's definition: > For any monad X, we can say that a function is monadic if it returns a value in the X Monad. plainly: > For any X that is equal to the number one, we can say that a function for it is equivalent to the number one if it returns a value that is the number one. in other words, the definition of a monad is just a function that returns 1 in all cases. This definition is super-simple. I have no idea why you object. here are some examples of monads written in C: int raise_to_zero(int x){ return 1; } this is a monad to raise a number to 0. Here is another one: int multiply_by_zero_and_add_one(int x){ return 1; } this is a monad for multiplying by zero and adding one. yet another would be: int divide_by_self(int x){ return 1; } You get the idea. Likewise there are monads for all sorts of times that you need a function to return one in all cases. It's really not hard. There's nothing circular or unusual about the OP's definition. He's just using plain everyday words we've all known since second grade, in their usual meanings. I'm at a loss why you would have trouble with this. NOTE: I'm certainly not an expert, so if I've left anything out, anyone should feel free to correct me! (pssst - this might be the only way of getting anything out of these folks.)
- StavrosK 12y agoOh, sorry, I'm not a native English speaker, which confused things. This is the clearest explanation on monads I've seen yet. I am going to try to implement these in Python right away, I think something like "return 1" should do the trick. Version 2 will support different values of 1.
- wz1000 12y agoYou are not getting my point. He is saying that something (which is kind of like a container or context for values, but even this is a false analogy) behaves like a monad (lets call the monad M) if and only if functions that take some value (of type a) and return a value (that may be of a different type) within the monad (so that would be M b, where M is another type) obey the monad laws when combined with bind and return. Monadic functions have the type (a -> M b) return has the type (a -> M a), so injecting a value into a monad bind has the type (M a -> (a -> M b) -> M b), or without currying, (M a, (a -> M b)) -> M b, so that given a monadic value (M a) and a monadic function (a -> M b), you get a result of type M b.