[m-dev.] Adding Loops to Mercury

Julien Fischer jfischer at opturion.com
Thu Jan 9 00:40:46 AEDT 2014


On Wed, Jan 8, 2014 at 11:58 PM, Mark Brown <mark at mercurylang.org> wrote:

> 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.


I was probably envisaging there be a more general class for sequence types
(which would IIRC would require constructor classes) instead of just
defining
something more specific like the above.

Cheers,
Julien.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/developers/attachments/20140109/bad5f633/attachment.html>


More information about the developers mailing list