[Haskell-beginners] Collapsing multiple case branches?
alexander.dunlap at gmail.com
Sat Jan 3 15:33:36 EST 2009
On Sat, Jan 3, 2009 at 12:04 PM, Thomas Davie <tom.davie at gmail.com> wrote:
> Hi Colin,
> These are called "pattern guards" – you can put any boolean expression in
Technically, those are just called "guards." "Pattern guards" are when
you also bind a pattern; it's a GHC extension. They look like this,
| Just y <- bar x = y + 1 -- this is the pattern guard. If bar x can
be matched with Just y, then y is bound and that guard path is taken.
Otherwise, evaluation falls through to the next guard option.
| otherwise = 0
More information about the Beginners