SNA=Shah Namrata Abhaykumar
SNA Consider the following eg.
SNA
SNA Using the above tanslation ,
SNA
SNA case (1,2) of { ~(a,b) = a + b ; _ -> 0 }
SNA
SNA == let { y = (1,2) }
SNA in
SNA let { x1' = case y of { (a,b) -> a }}
SNA in
SNAlet { x2' = case y of {
Namrata asks...
| So, when x1' + x2' is evaluated,
| Is (1,2) pattern matched against (a,b) twice -- once for x1' and once
| for x2' ??
The translation you give (correctly I think) expresses the required
*semantics*. But the translation is not the required *implementation*. A
compiler can do
Rob Turner <[EMAIL PROTECTED]> writes:
| How do you get a subtype in Haskell (or any other functional language
| come to that)? I'm thinking along the lines of (pseudo-notation):
|
| type weekday = {Mon, Tue, Wed, Thur, Fri}
| type weekend = {Sat, Sun}
| type day = weekend + weekday
The semantics of irrefutable pattern matching is given as,
case e0 of { ~p -> e ; _ -> e' }
= let { y = e0 }
in
let { x1' = case y of { p -> x1 } }
in ...
let { xn' = case y of { p -> xn } }
in
e[x1'/x1,x2'/x2 .. ,xn'/xn]
x1,..,xn a