[Haskell-cafe] The semantics of constructor patterns

Cristian Baboi cristian.baboi at gmail.com
Sun Dec 30 12:10:24 EST 2007

In section 4.3.3., chapter 4: Structured types and the semantics of  
pattern-matching,  by S.Peyton Jones and Philip Wadler, there is this  

Eval[[\(s p1 p2 ... pt).E]] (s a1 a2 ...at) = Eval[[\p1 ... \pt.E]] a1 ...  

The text say:
"To apply \(s p1 ... pt).E to an argument A we first evaluate A to find  
out what sort of object it is."
"Finally, if A was built with the same constructor as the patern, then the  
first rule applies."

What I don't get it :

(s a1 a2 ... at) must be the value of A in the semantic domain. Let call  
that value a.
Then how can one know if a was built with (s a1 a2 ... at) and not with  
(egg b1 b2) ?

More information about the Haskell-Cafe mailing list