| 66 | 70 | 2) {{{let}}} {''d,,1,,''; ''d,,2,,''} {{{in}}} ''e'' = {{{let}}} {''d,,1,,''} {{{in}}} (let {''d,,2,,''} {{{in}}} ''e'') |
| 67 | 71 | (when no identifier bound in ''d,,2,,'' appears free in ''d,,1,,'') |
| | 102 | Replace the first paragraph of [http://haskell.org/onlinereport/decls.html#sect4.5.2 section 4.5.2] '''Generalization''': |
| | 103 | |
| | 104 | {{{ |
| | 105 | #!html |
| | 106 | <div style="background: #ffcccc"> |
| | 107 | }}} |
| | 108 | The Hindley-Milner type system assigns types to a {{{let}}}-expression in two stages. First, the right-hand side of the declaration is typed, giving a type with no universal quantification. Second, all type variables that occur in this type are universally quantified unless they are associated with bound variables in the type environment; this is called ''generalization''. Finally, the body of the {{{let}}}-expression is typed. |
| | 109 | {{{ |
| | 110 | #!html |
| | 111 | </div> |
| | 112 | }}} |
| | 113 | |
| | 114 | with |
| | 115 | |
| | 116 | {{{ |
| | 117 | #!html |
| | 118 | <div style="background: #ccffcc"> |
| | 119 | }}} |
| | 120 | The Hindley-Milner type system assigns types to a {{{let}}}-expression in two stages: |
| | 121 | 1) The declaration groups are considered in dependency order. For each group, a type with no universal quantification is inferred for each variable bound in the group. Then, all type variables that occur in these types are universally quantified unless they are associated with bound variables in the type environment; this is called ''generalization''. |
| | 122 | |
| | 123 | 2) Finally, the body of the {{{let}}}-expression is typed. |
| | 124 | {{{ |
| | 125 | #!html |
| | 126 | </div> |
| | 127 | }}} |
| | 128 | |
| | 129 | Notes: |
| | 130 | * The original deals with {{{let}}}'s consisting of a single binding, instead of declaration groups. Note that we can no longer assume that a {{{let}}} has a single declaration group. |
| | 131 | * The original does not deal with functions, non-trivial patterns or recursion. |
| 92 | | The first paragraph of [http://haskell.org/onlinereport/decls.html#sect4.5.2 section 4.5.2] isn't quite right: |
| 93 | | |
| 94 | | The Hindley-Milner type system assigns types to a {{{let}}}-expression in two stages. First, the right-hand side of the declaration is typed, giving a type with no universal quantification. Second, all type variables that occur in this type are universally quantified unless they are associated with bound variables in the type environment; this is called ''generalization''. Finally, the body of the {{{let}}}-expression is typed. |
| 95 | | |
| 96 | | * It deals with {{{let}}}'s consisting of a single binding, instead of declaration groups. Note that we can no longer assume that a {{{let}}} has a single declaration group. |
| 97 | | * It does not seem to deal with functions, non-trivial patterns or recursion. |