Simon Peyton-Jones wrote:
| The report doesn't actually mention this translation although it is
| widely used to implement pattern bindings, and in some compilers (not
| GHC) the translation is done before type checking.
|
| What's interesting to me is that perhaps this gives us a way to
| understand what the static semantics of pattern bindings should be,
| absent MPB. e.g.

Yes, that's a fine point.  If this became the formal definition of the *static* 
semantics of pattern bindings, that would be a significant improvement, because 
it'd give us a precise way to answer the various questions I asked. (We might 
or might not like the answers, but at least we could answer them.)

Ok.  So I counter-propose that we deal with pattern bindings like this:

  The static semantics of a pattern binding are given by the following
  translation.  A binding 'p = e' has the same meaning as the set of
  bindings

    z = e
    x1 = case z of { p -> x1 }
    ...
    xn = case z of { p -> xn }

  where z is fresh, and x1..xn are the variables of the pattern p.

For bang patterns, I think it suffices to say that a bang at the top level of p is carried to the binding for z, and then separately define what banged variable bindings mean (i.e. add appropriate seqs).

Does anyone see any problems with this?

Oh, and I also propose to use the terminology "variable binding" instead of "simple pattern binding", which is currently used inconsistently in the report (see section 4.4.3.2).

Cheers,
        Simon
_______________________________________________
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime

Reply via email to