Talk:Haskell/MonadPlus

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search

Pardon my ignorance, but shouldn't that tree under the 'guard' section look like this?

   start
   |____________________________________________ ...
   |                     |                    |
x  1                     2                    3
   |_______________ ...  |_______________ ... |_______________ ...
   |      |      |       |      |      |      |      |      |
y  1      2      3       2      3      4      3      4      5
   |___...|___...|___... |___...|___...|___...|___...|___...|___...
   | | |  | | |  | | |   | | |  | | |  | | |  | | |  | | |  | | |
z  1 2 3  2 3 4  3 4 5   2 3 4  3 4 5  4 5 6  3 4 5  4 5 6  5 6 7


It looks like you're right. Maybe we should see what DavidHouse thinks... I suppose after a while, we should just go ahead and replace that diagram -- Kowey 13:17, 6 December 2006 (UTC)
(I'm pretty sure) he's right -- Felix C. Stegerman 08:35, 10 June 2007 (UTC)




Also, the 'guard' section contains:

So the empty list produced by the call to guard in the binding of gd will cause gd to be the empty list, and therefore ret to be the empty list.

The way I see it, since gd evaluates to [] (the empty list), ret is never called in (what evaluates to) concatMap (\_ -> ret x y z) []. Which means it should be (something like):

So the empty list produced by the call to guard in the binding of gd will cause gd to be the empty list. I.e. concatMap (\_ -> ret x y z) (guard $ x^2 + y^2 == z^2) evaluates to concatMap (\_ -> ret x y z) [], which evaluates to []). ret is never called.

(feel free to rephrase that)

-- Felix C. Stegerman 09:08, 10 June 2007 (UTC)