
On Tue, Oct 7, 2008 at 5:07 PM, Daniel Fischer
Am Dienstag, 7. Oktober 2008 22:09 schrieb Andrew Coppin:
Daniel Fischer wrote:
Maybe it is as simple as
raw_bind (xs:xss) f = do rsYs <- mapM f xs ~rsZ <- raw_bind xss f return (foldr union (cost rsZ) rsYs)
then rsZ should only be evaluated when it's needed
Ooo... "lazy pattern matching"? Can somebody explain to me, _very slowy_, exactly what that means? <snip> If I'm not mistaken, the rsZ variable shouldn't be evaluated until needed *anyway*, so what is lazy pattern matching buying me here?
That depends on how your Monad (and union) is implemented, it may or may not make a difference. I must admit that I didn't really look at the code you posted, so I don't know what would be the case here. It was just an easy thing to try which *might* help.
Unless you're pattern matching against a constructor, which rsZ is
not, I think lazy pattern matching is no different from regular
pattern matching.
--
Dave Menendez