Re: Here's a puzzle to fry your brains ....

1999-04-29 Thread Ross Paterson
John Launchbury wrote: test :: [Int] test = do (x,z) - [(y,1),(2*y,2), (3*y,3)] Just y - map isEven [z .. 2*z] return (x+y) isEven x = if even x then Just x else Nothing I would expect this to be equivalent to test = do (~(x,z), ~(Just y)) -

Re: Here's a puzzle to fry your brains ....

1999-04-29 Thread Wolfram Kahl
John Launchbury posed a nice puzzle about mutual recursive bindings in the do notation: test :: [Int] test = do (x,z) - [(y,1),(2*y,2), (3*y,3)] Just y - map isEven [z .. 2*z] return (x+y) isEven x = if even x then Just x else Nothing

Here's a puzzle to fry your brains ....

1999-04-28 Thread John Launchbury
Folks, My student Levent Erkok and I have been playing about with the idea of mutual recursive bindings in the do notation. Mostly it's clear how they should behave, but we struggle with the following example. I would love to hear some (considered) opinions about this. John.