[Haskell-cafe] questions on lazy pattern, StateT monad
wolfgang at jeltsch.net
Thu Nov 24 15:56:34 EST 2005
Am Donnerstag, 24. November 2005 21:37 schrieb Fan Wu:
> 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?
Often you need pattern matching for distinguishing different cases (e.g.,
empty vs. non-empty list). In these cases, lazy patterns are useless.
Our discussion was only about lazy patterns in conjunction with tuples. The
deeper reason for using lazy patterns was that we actually want unlifted
tuples (because we just want to group several things together) while Haskell
provides us only with lifted tuples. In such cases it might be generally
advisable to use lazy patterns. An alternative to using lazy patterns would
be to use unlifted tuples which come as an extension with GHC, named "unboxed
More information about the Haskell-Cafe