Quoting Patrick Smith (2018-10-16 18:32:48)
>The union function could verify that the two adaptors are the same,
>using the == operator, and panic if not. However, this breaks down if
>the adaptors, instead of being defined as struct{}, are defined as
>types which don't support ==.
On Tue, Oct 16, 2018 at 3:21 PM Ian Denhardt wrote:
> Quoting Patrick Smith (2018-10-16 18:04:05)
> >One way to avoid this is to supply the adaptor when the Set is
> created,
> >store it in the Set, and thereafter used the stored adaptor instead of
> >requiring an adaptor parameter.
>
Quoting Patrick Smith (2018-10-16 18:04:05)
>One way to avoid this is to supply the adaptor when the Set is created,
>store it in the Set, and thereafter used the stored adaptor instead of
>requiring an adaptor parameter.
This works for insert/member, but what about union, which takes
On Tue, Oct 16, 2018 at 12:01 PM Ian Denhardt wrote:
> * We don't actually need an adaptor for the zero value, since we can
> just declare a variable of the generic type:
>
> func MyFn(type T) {
> // x is the zero value, per usual initialization rules:
> var x T
>
True. Thi
I write this kind of code a lot when working in Elm (whose generics are
in a similar spot to the place you suggest). It's not the worst, and
there various approaches in related languages use to make the "adaptors"
more ergonomic.
I still like the idea of using interfaces to express constraints bet