[Haskell-cafe] Patter matching beginner question

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Sun Dec 16 23:59:41 EST 2007

On Dec 16, 2007, at 23:35 , Adam Smyczek wrote:

> case name of
> 	c_a -> ...
> 	c_b -> ...
> I get Patterns match(es) are overlapped.

You can't use arbitrary expressions in patterns; any name (not a data  
constructor) used in one creates a new lambda binding (shadowing any  
existing binding) which receives the value at that point in the  
pattern.  So

 > case name of
 >   c_a -> ...

captures the value of name in a new binding c_a.

brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH

More information about the Haskell-Cafe mailing list