[Haskell-cafe] do
jerzy.karczmarczuk at info.unicaen.fr
jerzy.karczmarczuk at info.unicaen.fr
Sun Oct 14 05:43:02 EDT 2007
Andrew Coppin writes:
> PR Stanley wrote:
>> What is the role of ">>"?
>> How is ">>" different to ">>="? I am aware that ">>=" is used for
>> sequencing parsers but that's all I know about it.
>
> foo >>= bar
>
> executes the action "foo" and passes its result to the function "bar"
> (which must then return another action, which is executed).
>
> foo >> bar
>
> executes the action "too", and then executes the action "bar". Any result
> generated by "foo" is discarded
===
I believe that our - sometimes helpful, sometimes not - answers should
regularly encourage the newbies to *READ* the tutorials, the documentation,
etc.
My goodness, is it really too difficult? Then, the answer would be given
by the default definition in the Prelude:
-- Minimal complete definition:
m >> k = m >>= \_ -> k
which means exactly that, >>= is the base, >> uses it, but doesn't care
about the argument. And shows that the verbal explanation, "actions",
"executed", etc. may not be true in general
I know that asking helpful humans is nicer than reading docs, but the latter
is usually more instructive, and often more efficient.
Jerzy Karczmarczuk
More information about the Haskell-Cafe
mailing list