[m-rev.] for review: fix compiler abort after unresolved overloading
Peter Wang
novalazy at gmail.com
Sun Aug 21 14:21:16 AEST 2022
On Sun, 21 Aug 2022 13:59:49 +1000 Julien Fischer <jfischer at opturion.com> wrote:
> > diff --git a/library/list.m b/library/list.m
> > index 5942c6c30..69a029de1 100644
> > --- a/library/list.m
> > +++ b/library/list.m
> > @@ -585,6 +585,42 @@
> > %
> > :- pred det_split_last(list(T)::in, list(T)::out, T::out) is det.
> >
> > + % add_separator(Sep, List, ListWithSep):
> > + %
> > + % Insert Sep between each pair of elements in List, and return
> > + % the result as ListWithSep.
> > + %
> > + % For example, add_separator("and", ["jan", "feb", "mar"], ListWithSep)
> > + % will bind ListWithSep to ["jan", "and", "feb", "and", "mar"].
> > + %
> > +:- pred add_separator(T::in, list(T)::in, list(T)::out) is det.
> > +
> > + % add_separators(Seps, List, ListWithSeps):
> > + %
> > + % Insert Seps between each pair of elements in List, and return
> > + % the result as ListWithSeps.
> > + %
> > + % For example, add_separators(["and", "then"], ["jan", "feb", "mar"],
> > + % ListWithSeps) will bind ListWithSeps to
> > + % ["jan", "and", "then", "feb", "and", "then", "mar"].
> > + %
> > +:- pred add_separators(list(T)::in, list(T)::in, list(T)::out) is det.
> > +
> > + % add_sep_separators(NonLastSeps, LastSeps, List, ListWithSeps):
> > + %
> > + % Insert NonLastSeps between each pair of elements in List except
> > + % the last pair, insert LastSeps between the last pair of elements,
> > + % and return the result as ListWithSeps. The middle "sep" in the name
> > + % is for the fact that are separate separators with non-last and last
> > + % pairs of elements.
> > + %
> > + % For example, add_separators(["and", "then"], ["and", "finally"],
> > + % ["jan", "feb", "mar"], ListWithSeps) will bind ListWithSeps to
> > + % ["jan", "and", "then", "feb", "and", "finaly", "mar"].
> > + %
> > +:- pred add_sep_separators(list(T)::in, list(T)::in, list(T)::in,
> > + list(T)::out) is det.
>
> Some alterantive suggestions for the names of these new predicates:
>
> interleave
> interleave_list
> interleave_list_last
>
> or:
>
> add_between
> add_between_list
> add_between_list_last
>
> My own preference would be the the interleave* naming.
I always knew add_separator as "intersperse" from Haskell.
Here's another suggestion:
intersperse
intersperse_list
intersperse_list_with_last
Peter
More information about the reviews
mailing list