Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heritage of the names of the monad operators

Tags:

haskell

monads

I'm currently reading up on category theory basics and try to make sense of the names Haskell assigns to monad operations, semantically.

All material I've come through refers to return as the unit map and join as the multiplication map (I'm OK with the name "join"). For >>= or bind I haven't even (yet) found a name common in math. Rather I've come across its flipped form, lift or -*, which in turn makes sense to me.

Actual questions (tldr):

  1. Why was "return" used instead of "unit"?
  2. Why was "bind" coined as nomenclature?
  3. Is there a name for "bind" in math world?
  4. What are the semantics the names "bind" and "return" should imply?
like image 575
Sebastian Graf Avatar asked Jun 27 '14 16:06

Sebastian Graf


People also ask

Who invented monads?

The mathematician Roger Godement was the first to formulate the concept of a monad (dubbing it a "standard construction") in the late 1950s, though the term "monad" that came to dominate was popularized by category-theorist Saunders Mac Lane.

What is a monad example?

Monads are simply a way to wrapping things and provide methods to do operations on the wrapped stuff without unwrapping it. For example, you can create a type to wrap another one, in Haskell: data Wrapped a = Wrap a. To wrap stuff we define return :: a -> Wrapped a return x = Wrap x.

What is a monad in simple terms?

A monad is an algebraic structure in category theory, and in Haskell it is used to describe computations as sequences of steps, and to handle side effects such as state and IO. Monads are abstract, and they have many useful concrete instances. Monads provide a way to structure a program.

Is maybe a monad?

Using Maybe is a good way to deal with errors or exceptional cases without resorting to drastic measures such as error . The Maybe type is also a monad. It is a simple kind of error monad, where all errors are represented by Nothing . A richer error monad can be built using the Either type.


1 Answers

Both names come from programming, rather than math. return, being used as the last statement of the do expression, makes it look very imperative: do {do_something; return result}. bind's name comes from its do translation: action >>= \x -> something translates to do {x <- action; something}, which looks like x is bound to the value returned from action.

As for bind's analog in math world, google "Kleisli triple".

like image 178
MigMit Avatar answered Sep 28 '22 07:09

MigMit