You're right, it's not properly described.
I still have the "revise the H98 report to include typos" job on my to-do
list.
You've found a definite shortcoming; I'll see how much work it would
be to fix.
Thanks
Simon
| -----Original Message-----
| From: Tommy Thorn [mailto:[EMAIL PROTECTED]]
| Sent: 29 June 2000 22:20
| To: [EMAIL PROTECTED]
| Subject: Desugaring of top-level pattern bindings?
|
|
| I'm puzzled by the Haskell 98 report, as it doesn't seem to explain
| how to desugar top-level pattern declarations, such as
|
| (x,y) = e
|
| In Section 4.4.3 (Function and Pattern Bindings) under Pattern
| Bindings it essentially says
|
| ``A simple pattern binding has form p = e. The pattern p is matched
| "lazily" as an irrefutable pattern, as if there were an implicit ~
| in front of it. See the translation in Section 3.12.''
|
| and then goes on the show how to eliminate guards.
|
| In Section 3.12 (Let Expressions) the translation given for
|
| let p = e1 in e0
|
| are
|
| case e1 of ~p -> e0
|
| if no variable in p appears free in e0, and
|
| let p = fix ( \ ~p -> e1) in e0
|
| otherwise.
|
| Both of these translations only work in a expression context and thus
| does not work for top level bindings.
|
| It look like the required translation would look a lot like clause (d)
| from Figure 3, ie.:
|
| v = e
| x1 = case v of p -> x1
| ...
| xn = case v of p -> xn
|
| where v is a new variable and x1,...,xn are the variables bound by p.
|
| Regards,
|
| Tommy
|