Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell monad: etymology versus meaning? [closed]

When I'm developing an understanding of some concept, I find it very unsatisfactory not to be able to see how the apparent etymology of the concept name relates to what I think I'm understanding about the concept. If I can't see the connection, I'm left with the feeling that there's some significant insight the name is trying to convey that I haven't yet discovered.

Monad: From Greek for unity. Mon = one; ad = a group or unit comprising a certain number. This composes to "A group or unit composed of one thing".

http://www.haskell.org/haskellwiki/All_About_Monads says:

"A monad is a way to structure computations in terms of values and sequences of computations using those values. Monads allow the programmer to build up computations using sequential building blocks, which can themselves be sequences of computations." ... "Other monads exist for building computations that perform I/O, have state, may return multiple results, etc"

Nothing much there about one-ness.

http://www.haskell.org/haskellwiki/Monad claims that the one-ness in term monad refers to the one output that a monad will produce. But given that any function produces one output, (and the above reference says "may return multiple results", not to mention out-of-band/error results), and there's nothing about the "group or unit", that explanation seems unconvincing.

Is there some better explanation?

[Edit: Responding to the "off topic" flag. My question is not about the etymology of the word "monad" per se. It is about the Haskell concept of monad, and how the roots of the word monad do or do not inform us about that concept, or perhaps actually misdirect us from understanding the topic. Given that monad is a famously hard-to-communicate concept in Haskell, this is certainly a question about programming.

That this is a salient issue is reinforced by the variation in respondent suggestions regarding how the roots in "monad" might relate to the topic at hand, including the observation that the explanation in Haskell's own documentation is highly suspect.

That said, I'm pretty satisfied with the answers given (thanks all!), so no need to reopen the topic. But I'd advocate not moving it elsewhere, so that others with the same confusion about an important Haskell concept can find it here.]

like image 851
gwideman Avatar asked Dec 30 '12 11:12

gwideman


People also ask

What is a monad in Haskell?

Haskell - Monads. Monads are nothing but a type of Applicative Functor with some extra features. It is a Type class which governs three basic rules known as monadic rules. Left Identity Law − The return function does not change the value and it should not change anything in the Monad.

What is do -notation in Haskell?

Nondeterminism using List monad to represent carrying multiple values In order to improve the look of code that uses monads, Haskell provides a special form of syntactic sugar called do -notation. For example, the following expression: which can be written more clearly by breaking it into several lines and omitting parentheses:

What is the best order to define return types in Haskell?

although the recommended order is to define return as pure if the two would otherwise end up being the same. Nondeterminism using List monad to represent carrying multiple values In order to improve the look of code that uses monads, Haskell provides a special form of syntactic sugar called do -notation. For example, the following expression:

What does a program in Haskell look like?

When using do -notation and a monad like State or IO, programs in Haskell look very much like programs written in an imperative language as each line contains a statement that can change the simulated global state of the program and optionally binds a (local) variable that can be used by the statements later in the code block.


1 Answers

Is there some better explanation?

Short answer: No, there really isn't.

Slightly less short answer: It's almost certainly related to "monoid", and not related to any other use of "monad" (there are at least two), and the term was coined at a gathering of mathematicians so there's likely not even a written source that's the first use of the term.

Longer answer with quotes and citations: The one I wrote here.

That claim on the wiki about the alleged meaning seems very dubious to me, incidentally.

like image 157
C. A. McCann Avatar answered Sep 21 '22 02:09

C. A. McCann