> They are useful not only in conjunction with infinite data structures. Take > my example state transformer "everything" and modify it so that it calls next > exactly two times, not infinitely many times, and outputs a pair of the > outputs of the two next invocations. > > Now let's assume you use this pair in a context where only its first component > is used. Without lazy patterns, next would be invoked two times although it > need to be invoked only one time. So you might have unnecessary evaluation. > And you might have something even worse. Let's assume that when we apply the > function making up next on the output state of the first next invocation then > we get _|_. Without lazy patterns, just using the output of the first next > invocation would result in your program aborting. Of course, it shouldn't do > so.
This is a good example! But now I got the impression that pattern match failure could happen in many places, so unless you want it to fail loudly, you shall always use lazy pattern? Thanks, Fan _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe