Re: [Haskell-cafe] Join and it's relation to >>= and return

I am pretty sure, that >>= is to monads what * is to for example natural numbers, but I don't know what the inverse of >>= is. And I can't really find it anywhere on the web(papers, websites, not a single sole does mention it. It should have type, at least that's what I think: inv::M a->M b I say this, because I find this definition of a multiplication operation: 1. There exists a unique special element called neutral such that the operation on any element and the neutral does not change the element. 2. For every element there exists an inverse such that the operation on an element and its inverse is always neutral. 3. The operation is associative: it does not matter how you apply the operation to three elements. You may apply it to the first two and then to the result and the third element. Or you may first apply the operation to the last two and then to the first and the result of the previous operation. An operation may also be commutative 4. The order of two elements in operation is not important. According to 2 there should be an inverse. For join such an inverse is simple: to apply the type constructor on the monad. But I tried to somehow link it with bind, but than the types don't seem to match. So to be concrete: what's the inverse of bind? If I did make some errors, please tell me so. __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/

hi ron, here are the relations between the two formulations of monads: (using haskell notation) map f m = m >>= (return . f) join m = m >>= id m >>= f = join (fmap f m) there are quite a few general concepts that you need to understand in what sense monads are monoids, but to understand how monads work you don't need to know that. Ron de Bruijn wrote:
I am pretty sure, that >>= is to monads what * is to for example natural numbers, but I don't know what the inverse of >>= is. And I can't really find it anywhere on the web(papers, websites, not a single sole does mention it.
this is not quie correct. (join & return) for a monad are like (*,1) or (+,0) for the set of integers. however those operations on integers have more structure than join and return. there is no operation for "inverse". in mathematical terms: monads are a monoid (given that the notion is generalized considerably from its usual use), and not a group. if one was to add such an operation (i am not sure what it would do), but it would be of type: inverse :: M a -> M a (and of course must satisfy some laws) also while you are pondering these things, it may be useful to use the "backward join" (=<<) :: (a -> m b) -> (m a -> m b). the reason for that is that strictly speaking tha arrow in the middle is different from the left and the right arrows i am not sure how useful this information is for you, but if you have more questions ask away -iavor
It should have type, at least that's what I think: inv::M a->M b
I say this, because I find this definition of a multiplication operation:
1. There exists a unique special element called neutral such that the operation on any element and the neutral does not change the element. 2. For every element there exists an inverse such that the operation on an element and its inverse is always neutral. 3. The operation is associative: it does not matter how you apply the operation to three elements. You may apply it to the first two and then to the result and the third element. Or you may first apply the operation to the last two and then to the first and the result of the previous operation.
An operation may also be commutative
4. The order of two elements in operation is not important.
According to 2 there should be an inverse. For join such an inverse is simple: to apply the type constructor on the monad. But I tried to somehow link it with bind, but than the types don't seem to match. So to be concrete: what's the inverse of bind?
If I did make some errors, please tell me so.
__________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/ _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Iavor S. Diatchki wrote:
Ron de Bruijn wrote:
I am pretty sure, that >>= is to monads what * is to for example natural numbers, but I don't know what the inverse of >>= is. And I can't really find it anywhere on the web(papers, websites, not a single sole does mention it.
this is not quie correct. (join & return) for a monad are like (*,1) or (+,0) for the set of integers. however those operations on integers have more structure than join and return.
there is no operation for "inverse". in mathematical terms: monads are a monoid (given that the notion is generalized considerably from its usual use), and not a group. if one was to add such an operation (i am not sure what it would do), but it would be of type: inverse :: M a -> M a (and of course must satisfy some laws)
I have *nothing* to add, just a question. Do you /anybody/ know of any edible work on ADJUNCTIONS in the context of Haskell structures? Perhaps instead of searching for 'inverses' one should think more about adjoints?... Jerzy Karczmarczuk

On Jun 9, 2004, at 9:39 AM, Jerzy Karczmarczuk wrote:
I have *nothing* to add, just a question. Do you /anybody/ know of any edible work on ADJUNCTIONS in the context of Haskell structures? Perhaps instead of searching for 'inverses' one should think more about adjoints?...
Yes, I think this is the right way to go. If you look at work by Power, Thielecke and Streicher on continuations [*], you will find that they model type negation as a self-adjoint functor on a closed premonoidal category, and IIRC a closed premonoidal category is equivalent to a thing called a closed kappa-category with a computational monad on it. The self-adjointness corresponds to the involutivity of negation. This all depends on the tensor product being commutative. It's also possible to drop commutativity, in which case you end up with _two_ exponentials, also called residuals, corresponding to the two ways to curry a non-commutative product. Such a category can serve as a proof-theoretic model for Lambek calculus, which is used in categorial grammar. In this situation, if you demand a multiplicative inverse, or equivalently a dual to the unit, you get _two_ negations or (better I think) `dualizers'. Barr treats this in a few of his papers, including [1], and [2] for the simpler commutative case. There is a neat way of forming such categories, called the Chu construction [2], which has provoked much interest in the categorical community. I once wrote some notes on something I called action logic, which tried to organize these ideas at a simpler level. The logic was non-commutative and had two dualizers like I said, and was designed to be sound and complete for a model where every proposition was interpreted by an adjoint pair of functions (or, just a Galois connection), and dualization by replacing a function by its (unique) adjoint. It all worked out very nicely because adjoints have such neat properties. I still have the notes if you're interested. [*] CiteSeer seems kind of broken, so try: http://www.google.com/search?q=site%3Aciteseer.ist.psu.edu+thielecke [1] Michael Barr, Non-symmetric *-autonomous categories, 1999. ftp://ftp.math.mcgill.ca/pub/barr/asymmps.zip [2] http://citeseer.ist.psu.edu/251562.html [3] http://citeseer.ist.psu.edu/barr96chu.html Regards, Frank

--- "Iavor S. Diatchki"
hi ron,
here are the relations between the two formulations of monads: (using haskell notation)
map f m = m >>= (return . f) join m = m >>= id
m >>= f = join (fmap f m)
there are quite a few general concepts that you need to understand in what sense monads are monoids, but to understand how monads work you don't need to know that.
Ron de Bruijn wrote:
I am pretty sure, that >>= is to monads what * is to for example natural numbers, but I don't know what the inverse of >>= is. And I can't really find it anywhere on the web(papers, websites, not a single sole does mention it.
this is not quie correct. (join & return) for a monad are like (*,1) or (+,0) for the set of integers. however those operations on integers have more structure than join and return.
there is no operation for "inverse". in mathematical terms: monads are a monoid (given that the notion is generalized considerably from its usual use), and not a group. if one was to add such an operation (i am not sure what it would do), but it would be of type: inverse :: M a -> M a (and of course must satisfy some laws)
also while you are pondering these things, it may be useful to use the "backward join" (=<<) :: (a -> m b) -> (m a -> m b). the reason for that is that strictly speaking tha arrow in the middle is different from the left and the right arrows
i am not sure how useful this information is for you, but if you have more questions ask away -iavor I found out what a group is: A group is a monoid each of whose elements is invertible.
Only I still find it weird that join is called a multiplication, because according to the definition of multiplication, there should be an inverse. I think, thus that multiplication is only defined on a group. And now still remains: why do they call it a multiplication, while by definition it's not. Or should I understand it as: there's a concept called multiplication and for different structures there's a definition? I think, now I think over it, that it would seem logical. It could be possible that the definition is incorrect, though. Does anyone knows of a definition that is more general (and not absolute nonsens ;))? The information you give me is *very* usefull, because I don't just want to work with monads, I truly want to understand them. Ron __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/

<snip> ?! I found out what a group is: ?! A group is a monoid each of whose elements is ?! invertible. ?! OK. ?! Only I still find it weird that join is called a ?! multiplication, because according to the definition of ?! multiplication, there should be an inverse. I think, No, it ain't. If you take the natural numbers (0,1,2,3,...), you have a group structure, with unit being 1 and with multiplication being multiplication. If an inverse for 0 would exist, the would be a number x for which 0*x=x*0=1, which is absurd. It is more even subtle if one considers the rotation group. The unit is keeping an object on its place. The multiplication is doing rotations sequently. Allright, one has an inverse here, but the rule (a*b)*c = a*(b*c) doesn't occur; try it with a banana or an apple! ?! thus that multiplication is only defined on a group. ?! And now still remains: why do they call it a ?! multiplication, while by definition it's not. Or In mathematics man call things first and then deduces the rules because of mathematicians hate making explicit coercions (or type dependencies) all the time! The most simple structure for which the word "multiplication" is used, as far as I know is a semigroup (a monoid without a unit). ?! should I understand it as: there's a concept called ?! multiplication and for different structures there's a ?! definition? I think, now I think over it, that it ?! would seem logical. ?! ?! It could be possible that the definition is incorrect, ?! though. Does anyone knows of a definition that is more ?! general (and not absolute nonsens ;))? ?! Well, the most general definitions are called "abstract nonsense". ?! The information you give me is *very* usefull, because ?! I don't just want to work with monads, I truly want to ?! understand them. ?! Please make a distinction betwixt "monoids" and "monads". The first is a group without an invertion. The latter is a construction in category theory (=abstract nonsense), for which the word has its origin on monoids, but in (functional) programming one usually means a specific construction (OK, based on monads) doing things which are much harder doing directly. Eugenio Moggi has made understandible papers on monads. Look on: http://www.disi.unige.it/person/MoggiE/publications.html and search for "monad" in the year 1991 or later. ?! Ron ?! Rik

G'day all.
Quoting Rik van Ginneken
It is more even subtle if one considers the rotation group. The unit is keeping an object on its place. The multiplication is doing rotations sequently. Allright, one has an inverse here, but the rule (a*b)*c = a*(b*c) doesn't occur; try it with a banana or an apple!
Wrong. Rotations do indeed form a group. In three dimensions, it's isomorphic to the unit quaternion group. I think you're thinking of unit octonions, which don't form a group because octonion multiplication is not associative in general.
Please make a distinction betwixt "monoids" and "monads". The first is a group without an invertion.
...or a semigroup with an identity.
The latter is a construction in category theory (=abstract nonsense),
Them's fighting words! Cheers, Andrew Bromage

At 08:20 09/06/04 -0700, Ron de Bruijn wrote:
Only I still find it weird that join is called a multiplication, because according to the definition of multiplication, there should be an inverse.
For real or rational numbers, maybe. But also think about Integers, or matrices. [ 1 2 ] * [ 3 ] = [ 11 ] [ 4 ] [ 1 2 ] * [ 1 ] = [ 11 ] [ 5 ] [ -3 5 ] * [ 3 ] = [ 11 ] [ 4 ] Where's the inverse here? #g ------------ Graham Klyne For email: http://www.ninebynine.org/#Contact

On Wednesday 09 June 2004 17:20, Ron de Bruijn wrote:
--- "Iavor S. Diatchki"
wrote: Only I still find it weird that join is called a multiplication, because according to the definition of multiplication, there should be an inverse. I think, thus that multiplication is only defined on a group. And now still remains: why do they call it a multiplication, while by definition it's not. Or should I understand it as: there's a concept called multiplication and for different structures there's a definition? I think, now I think over it, that it would seem logical. It could be possible that the definition is incorrect, though. Does anyone knows of a definition that is more general (and not absolute nonsens ;))?
The term "multiplication" as it stands (i.e. without context) is not a defined mathematical concept. I.e. there is no (generally accepted) definition. Of course multiplication of numbers, vectors, matrices, functions etc... are all well defined. Multiplication isn't even constrained to the operation on a semi-group as the example of multiplication of scalars to vectors shows. You probably would not use the term "multiplication" for anything that is not at least a function f: A, B -> C where A, B, and C are sets (or at least classes). If A=B, then you would probably assume associativity, though there migth be "counter-examples" even for this rule. Ben
participants (8)
-
ajb@spamcop.net
-
Benjamin Franksen
-
Frank Atanassow
-
Graham Klyne
-
Iavor S. Diatchki
-
Jerzy Karczmarczuk
-
Rik van Ginneken
-
Ron de Bruijn