# #! Constructor Pattern Matching

Shiv shiv@balrog.ece.ucsb.edu
Thu, 31 Aug 2000 11:24:45 -0700 (PDT)


Hi,

Could someone tell me why the following program is legal:

////////////
module test1
import StdEnv
:: Test = Pair Int Int
foo :: Test -> Int
foo ab # (Pair a b) = ab
       = a+b
Start = foo (Pair 1 2)
/////////////

whereas the following one is illegal?

////////////
module test2
import StdEnv
:: Test = Pair Int Int
foo :: Test -> Int
foo ab #! (Pair a b) = ab // illegal pattern
       = a+b
Start = foo (Pair 1 2)
/////////////

The language manual was difficult to decipher. I know that #! allows
pattern matching on the left with tuples, but why not Constructors? I
thought they were on equal footing.

Any help/advice/explanation will be appreciated. Thanks,

--shiv--