... | ... | @@ -100,7 +100,8 @@ Dependency groups are smaller, and more programs type-check. |
|
|
|
|
|
|
|
|
|
|
|
Replace the body of [ section 4.5.1](http://haskell.org/onlinereport/decls.html#sect4.5.1) **Dependency analysis**
|
|
|
Replace the body of [ section 4.5.1](http://haskell.org/onlinereport/decls.html#sect4.5.1) **Dependency analysis**:
|
|
|
|
|
|
|
|
|
|
|
|
>
|
... | ... | @@ -150,6 +151,7 @@ Replace the body of [ section 4.5.1](http://haskell.org/onlinereport/decls.html# |
|
|
> > > (when no identifier bound in *d<sub>2</sub>* appears free in *d<sub>1</sub>*)
|
|
|
> > >
|
|
|
> > >
|
|
|
> > >
|
|
|
> >
|
|
|
>
|
|
|
|
... | ... | @@ -157,6 +159,7 @@ Replace the body of [ section 4.5.1](http://haskell.org/onlinereport/decls.html# |
|
|
with:
|
|
|
|
|
|
|
|
|
|
|
|
>
|
|
|
>
|
|
|
> In general the static semantics are given by the normal Hindley-Milner inference rules. A dependency analysis transformation is first performed to increase polymorphism.
|
... | ... | @@ -198,6 +201,7 @@ with: |
|
|
> A *declaration group* is a minimal set of bindings of mutually dependent variables. Hindley-Milner type inference is applied to each declaration group in dependency order. The order of declarations in `where`/`let` constructs is irrelevant.
|
|
|
>
|
|
|
>
|
|
|
>
|
|
|
|
|
|
|
|
|
Notes:
|
... | ... | @@ -206,21 +210,53 @@ Notes: |
|
|
- also tightens up the original wording, which didn't mention that the declarations had to be in the same list and also defined *declaration group* but not dependency.
|
|
|
- the dependency analysis transformation formerly listed in this section is no longer always possible.
|
|
|
|
|
|
## Other issues
|
|
|
|
|
|
Replace the first paragraph of [ section 4.5.2](http://haskell.org/onlinereport/decls.html#sect4.5.2) **Generalization**:
|
|
|
|
|
|
- The Report sometimes speaks of "value bindings", "value declarations" or "function and pattern bindings". It might be best to standardize on "value bindings".
|
|
|
- Similarly "declaration groups" might more precisely be called "binding groups", since other kinds of declaration are not involved.
|
|
|
|
|
|
|
|
|
The first paragraph of [ section 4.5.2](http://haskell.org/onlinereport/decls.html#sect4.5.2) isn't quite right:
|
|
|
>
|
|
|
>
|
|
|
> 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.
|
|
|
>
|
|
|
>
|
|
|
>
|
|
|
|
|
|
|
|
|
with
|
|
|
|
|
|
|
|
|
|
|
|
>
|
|
|
>
|
|
|
> 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.
|
|
|
> The Hindley-Milner type system assigns types to a `let`-expression in two stages:
|
|
|
>
|
|
|
>
|
|
|
> >
|
|
|
> >
|
|
|
> > 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*.
|
|
|
> >
|
|
|
> >
|
|
|
>
|
|
|
|
|
|
>
|
|
|
> >
|
|
|
> >
|
|
|
> > 2) Finally, the body of the `let`-expression is typed.
|
|
|
> >
|
|
|
> >
|
|
|
> >
|
|
|
>
|
|
|
|
|
|
- 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.
|
|
|
- It does not seem to deal with functions, non-trivial patterns or recursion. |
|
|
|
|
|
Notes:
|
|
|
|
|
|
|
|
|
- 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.
|
|
|
- The original does not deal with functions, non-trivial patterns or recursion.
|
|
|
|
|
|
## Other issues
|
|
|
|
|
|
|
|
|
- The Report sometimes speaks of "value bindings", "value declarations" or "function and pattern bindings". It might be best to standardize on "value bindings".
|
|
|
- Similarly "declaration groups" might more precisely be called "binding groups", since other kinds of declaration are not involved. |