4 ms·
> You're defining a monad by using itself in the definition! A definition is recursive if it recurses. The parent is not defining a monad with that sentence, h
by wz1000 12y ago
> You're defining a monad by using itself in the definition! A definition is recursive if it recurses.
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
> I sort of understand the three laws after that, but it's like someone asking "what are operations on numbers" and getting the answer "operation is any operation that's associative, commutative, etc". It does nothing to explain monads to me, it just tells me that a monad is any thing that obeys three things. That information is completely useless to me.
The thing is that there is not much more to a monad than those three laws and the two functions(return and bind/join).
Nonads are remarkable because lots of things happen to behave like monads(i.e have return and bind defined in a way that follows those operations). This includes interpreters, actions with side affects, non deterministic computations, computations with the possibility of failure and many other things.
Monads are useful because they let you write code that is reusable across all monads and not just the one you happen to be coding for. If you look at code that is written like this, after enough experience you will get a vague idea of what it does, but its actual function will almost completely differ based on what kind of monad you use it for. This gives you a great amount of flexibility and refactorability as you can tweak and extent monads or create entirely new monads while still having this great mass of reusable code already written for you to use.
Like the OP says, a monad is not some tangible concept like an object or a function. It is a concept that groups other concepts together.
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.
- 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.
- 12y ago