ML like pattern matching

Cagdas Ozgenc co19@cornell.edu
Fri, 22 Aug 2003 20:00:25 +0300


Thanks.

I was reading some codes in ML, and it was commented this was the case. I
didn't know Haskell had the equivalent behavior. I always thought once the
pattern was matched there is no going back.

>> I may be confused about what you're asking for, but Haskell does
>> this by default:
>>
>> foo (Left x) | x>3 = "bar"
>> foo _ = "splat"
>>
>> Main> foo (Left 5)
>> "bar"
>> Main> foo (Left 1)
>> "splat"