[m-rev.] for review: allow repeated type variables in instance heads

Ian MacLarty imaclarty at opturion.com
Fri Jul 5 16:16:28 AEST 2013


On Thu, Jul 4, 2013 at 2:53 AM, Julien Fischer <jfischer at opturion.com> wrote:
>
> For review by anyone.
>
> Allow repeated type variables in type class instance heads.
>
> The Mercury compiler has long required that all of the type variables
> referred
> to in type class instance head be distinct.  There is no particularly good
> reason for this restriction -- the implication that it helps to ensure that
> there are no overlapping instances in the reference manual is misleading,
> since
> the way that we do that (at least in the C grades), by using the names of
> the
> base_typeclass_infos, is not affected by type variables.
>
> The major implementation detail needed to support repeated type variables in
> instance declarations is that when doing context reduction, we must do full
> matching of instances against constraints (i.e. we need to keep track of the
> type variable bindings).  Since we already do this, the only change required
> to
> support repeated type variables is to remove the error checking that
> prevents
> it.
>
> compiler/check_typeclass.m:
>         Do not require that type variables in instance heads be distinct.
>
> doc/reference_manual.texi:
>         Document that repeated type variables are now allowed in instance
>         heads.
>
> NEWS:
>         Announce the change.
>

Looks fine.

Ian.



More information about the reviews mailing list