[Haskell-cafe] Bind as a sequencing operator (Was: evaluation semantics of bind)

Jake McArthur jake at pikewerks.com
Thu Feb 5 14:21:46 EST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

mail at justinbogner.com wrote:
|   [1..2] >>= return . (^2)
|
| This says "generate the list [1..2] and then use it to generate a list
| of squares". It's more than just application, it's a description of a
| sequence of actions. The whole point of list comprehensions (which is
| the only reason to have a list monad, as far as I know) is to think
| of it this way rather than as an application of concatMap.

The problem with your description is that you said "and then." The
result will be generated lazily. There is no sequencing here. Consider:

~    do x <- [0..]
~       y <- [0..9]
~       return (x, y)

Which list is generated first?

| As for Reader, I don't know enough about it to say anything.

Reader provides an immutable value that can be retrieved at any point in
the monad. There are no monadic side effects, so it doesn't really mean
much to say that anything happens in any particular order.

- - Jake
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkmLPEoACgkQye5hVyvIUKlaJACePGL6FdevDAmREsl/H9u7jjxS
bKsAoMzEkpw6XjOVg4xql8d4NN47lg8d
=jNtS
-----END PGP SIGNATURE-----


More information about the Haskell-Cafe mailing list