Changes between Initial Version and Version 3 of Ticket #76


Ignore:
Timestamp:
Jan 19, 2006 9:57:42 AM (10 years ago)
Author:
simonpj@…
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #76

    • Property Type changed from task to enhancement
    • Property Component changed from HaskellPrime to Proposal
  • Ticket #76 – Description

    initial v3  
    1 In this note I describe a proposed extension to Haskell that John Launchbury
    2 and I came up with while walking around Charleston after POPL'06.
    3 
    41== Goal ==
    52Our goal is to make it easier to write strict programs in
     
    9693which evaluates the (f x), thereby giving a strict `let`.
    9794
    98 Here is a more realistic example
     95Here is a more realistic example, a strict version of partition:
    9996{{{
    100         partition p [] = ([], [])
    101         partition p (x:xs)
     97        partitionS p [] = ([], [])
     98        partitionS p (x:xs)
    10299          | p x       = (x:ys, zs)
    103100          | otherwise = (ys, x:zs)
    104101          where
    105             !(ys,zs) = partition p xs
     102            !(ys,zs) = partitionS p xs
    106103}}}
    107104The bang in the where clause ensures that the recursive
     
    109106write
    110107{{{
    111         partition p [] = ([], [])
    112         partition p (x:xs)
    113           = case partition p xs of
     108        partitionS p [] = ([], [])
     109        partitionS p (x:xs)
     110          = case partitionS p xs of
    114111                (ys,zs) | p x       = (x:ys, zs)
    115112                        | otherwise = (ys, x:zs)
     
    120117needed in this example but often useful).
    121118
     119The
     120
    122121== Changes to the Report ==
    123122
    124123The changes to the Report would be these
    125124
    126 * Section 3.17, add pat ::= !pat to the syntax of patterns.
     125 * Section 3.17, add pat ::= !pat to the syntax of patterns.
     126   We would need to take care to make clear whether
     127{{{
     128   f !x = 3
     129}}}
     130   was a definition of the function "!", or of "f".  (There is
     131   a somewhat similar complication with n+k patterns; see the
     132   end of 4.3.3.2 in the Report.  However we probably do not
     133   want to require parens thus
     134{{{
     135   f (!x) = 3
     136}}}
     137   which are required in n+k patterns.
    127138
    128 * Section 3.17.2: add new bullet 10, saying "Matching
    129   the pattern "!pat" against a value "v" behaves as follows:
    130         - if v is bottom, the match diverges
    131         - otherwise, "pat" is matched against "v".
     139 * Section 3.17.2: add new bullet 10, saying "Matching
     140   the pattern "!pat" against a value "v" behaves as follows:
     141   * if v is bottom, the match diverges
     142   * otherwise, "pat" is matched against "v".
    132143
    133 * Fig 3.1, 3.2, add a new case (t):
     144 * Fig 3.1, 3.2, add a new case (t):
    134145{{{
    135146   case v of { !pat -> e; _ -> e' }
     
    137148}}}
    138149
    139 * Section 3.12 (let expressions).  In the translation box, wherever
    140   there is a bang right at the top of a pattern on the LHS of the
    141   translation rule, omit the implicit tilde that occurs at the top
    142   of the pattern on the RHS of the rule.
     150 * Section 3.12 (let expressions).  In the translation box, wherever
     151   there is a bang right at the top of a pattern on the LHS of the
     152   translation rule, omit the implicit tilde that occurs at the top
     153   of the pattern on the RHS of the rule.
    143154
    144 The last point is the only delicate one, but I think it's sufficient
    145 to do the job.
     155The last point is the only delicate one. If we adopt this proposal
     156we'd need to be careful about the semantics.  For example, are
     157bangs ok in recursive bindings? (Yes.) And for
     158non-recursive bindings the order of the bindings shouldn't matter.