[m-users.] Using insts to simulate dependent-type features.
Mark Brown
mark at mercurylang.org
Fri Jul 19 02:13:34 AEST 2019
Hi,
On Thu, Jul 18, 2019 at 8:01 PM Julien Fischer <jfischer at opturion.com> wrote:
> The major issue with using insts like the above is that the standard
> library doesn't use polymorphic modes (for the most part), so the
> subtype information tends to get lost quite easily.
There's that, and also that it doesn't tend to provide specific modes
that constrain the subtype. For example, list.append could have these
additional modes:
:- mode append(in(non_empty_list), in, out(non_empty_list)) is det.
:- mode append(in, in(non_empty_list), out(non_empty_list)) is det.
Similarly for list.reverse, list.reverse_prepend, list.map*, etc.
Also, some existing modes could be tightened, such as the (in, in,
out) mode of list.insert.
Mark
More information about the users
mailing list