[m-dev.] Adding Loops to Mercury

Mark Brown mark at mercurylang.org
Wed Jan 8 23:58:56 AEDT 2014

Hi Peter,

On Mon, Jan 6, 2014 at 12:37 PM, Peter Schachte <pschachte at gmail.com> wrote:
> The big problem, as observed earlier, is the lack of support for
> constructor classes.  That means we can't allow people to define
> sequence_empty and sequence_next for their own types, so this would be
> limited to lists.

When I try this, the problem I hit is the restriction on typeclass
instances not being able to have variables as parameters.

Here's a typeclass I want to define:

    :- typeclass foldable(C, E) where [
        pred fold(pred(E, A, A), C, A, A),
        mode fold(in(pred(in, in, out) is det), in, in, out) is det

Currently in Mercury I can define an instance for foldable(map(K, V),
pair(K, V)), but not foldable(list(T), T) or foldable(set(T), T).

I'm not sure why Julien brought constructor classes up.


More information about the developers mailing list