
On Jan 13, 2008, at 13:59 , Fernando Rodriguez wrote:
When I compile this code, ghc complains about some overlapped patterns in function depth. What on Earth is ghc talking about? O:-)
emptyBT = EmptyTree
depth emptyBT = 0 depth (NodeBT _ left right) = max (1 + depth left) (1 + depth right)
If you use a variable in a pattern match, it creates a new binding which irrefutably matches the corresponding argument. In other words, you get a new local variable "emptyBT", ignoring your global. You must use the actual constructor instead. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH