# Difference between revisions of "Talk:What a Monad is not"

(→In what sense is Maybe commutative?: new section) |
|||

Line 17: | Line 17: | ||

[Nicolas Pouillard]: The point was that the IO monad is not a value, of course there is values of type "IO Int". However the record/dictionary is a value and one could say that it is the monad. |
[Nicolas Pouillard]: The point was that the IO monad is not a value, of course there is values of type "IO Int". However the record/dictionary is a value and one could say that it is the monad. |
||

+ | |||

+ | == In what sense is Maybe commutative? == |
||

+ | |||

+ | It seems to me that <hask>Maybe</hask> is not really a commutative monad, as claimed here and at [[Monad]]. |
||

+ | |||

+ | |||

+ | <haskell> |
||

+ | do |
||

+ | x <- Nothing |
||

+ | y <- undefined |
||

+ | return (x+y) |
||

+ | </haskell> |
||

+ | produces <hask>Nothing</hask> whereas |
||

+ | <haskell> |
||

+ | do |
||

+ | y <- undefined |
||

+ | x <- Nothing |
||

+ | return (x+y) |
||

+ | </haskell> |
||

+ | produces <hask>undefined</hask>. |

## Revision as of 17:14, 19 June 2014

## Nicolas Pouillard Comments

I disagree with: "So ordering is not in any way essential to what a monad is."

There is commutative monads, great! Other than that the order is important. Moreover there is nothing wrong to see >>= as a sequencing operator.

I also disagree the "IO is impure" paragraph: Indeed only IO will trigger visible side effects, but this is only due to the common evaluation of IO primitives. Moreover I would say that only the runtime system is impure because it does reduce 'main :: IO ()', other than that we are just building a computation plan in a pure way.

Although I agree that the common issue is too mix monad and impurity, and the impurity question is only releated to IO.

## "Monads are not values"

Yes they are! But they are not of the type of their arguments. For instance "return 3" is a value that has (or can have) type "IO Int". But it is not a value of type Int. —Ashley Y 23:44, 23 November 2009 (UTC)

[Nicolas Pouillard]: The point was that the IO monad is not a value, of course there is values of type "IO Int". However the record/dictionary is a value and one could say that it is the monad.

## In what sense is Maybe commutative?

It seems to me that `Maybe`

is not really a commutative monad, as claimed here and at Monad.

```
do
x <- Nothing
y <- undefined
return (x+y)
```

produces `Nothing`

whereas

```
do
y <- undefined
x <- Nothing
return (x+y)
```

produces `undefined`

.