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

Reply via email to