<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Wed, Jan 8, 2014 at 11:58 PM, Mark Brown <span dir="ltr"><<a href="mailto:mark@mercurylang.org" target="_blank">mark@mercurylang.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Peter,<br>
<div class="im"><br>
On Mon, Jan 6, 2014 at 12:37 PM, Peter Schachte <<a href="mailto:pschachte@gmail.com">pschachte@gmail.com</a>> wrote:<br>
</div><div class="im">> The big problem, as observed earlier, is the lack of support for<br>
> constructor classes.  That means we can't allow people to define<br>
> sequence_empty and sequence_next for their own types, so this would be<br>
> limited to lists.<br>
<br>
</div>When I try this, the problem I hit is the restriction on typeclass<br>
instances not being able to have variables as parameters.<br>
<br>
Here's a typeclass I want to define:<br>
<br>
    :- typeclass foldable(C, E) where [<br>
        pred fold(pred(E, A, A), C, A, A),<br>
        mode fold(in(pred(in, in, out) is det), in, in, out) is det<br>
    ].<br>
<br>
Currently in Mercury I can define an instance for foldable(map(K, V),<br>
pair(K, V)), but not foldable(list(T), T) or foldable(set(T), T).<br>
<br>
I'm not sure why Julien brought constructor classes up.</blockquote><div><br></div><div>I was probably envisaging there be a more general class for sequence types</div><div>(which would IIRC would require constructor classes) instead of just defining</div>
<div>something more specific like the above.</div><div><br></div><div>Cheers,</div><div>Julien.</div><div><br></div><div><br></div><div> </div></div><br></div></div>