Ah sorry, I misunderstood. Please disregard :)

On Wed, Jun 17, 2020, 20:36 Axel Wagner <axel.wagner...@googlemail.com>
wrote:

> You can always combine multiple interface constraints:
>
> type ConstraintA(type A) interface {
>     Foo() A
> }
>
> type ConstraintB(type B) interface {
>     Bar() B
> }
>
> type CombinedConstraint(type A, B) interface {
>     (ConstraintA(A))
>     (ConstraintB(B))
> }
>
> func F(type A, B CombinedConstraint(A, B)) (...) { ... }
>
> So I don't think removing contracts prevents you from getting the same if
> you find it more readable.
>
> On Wed, Jun 17, 2020, 18:58 Denis Cheremisov <denis.cheremi...@gmail.com>
> wrote:
>
>> IMO a groups of constraints are horrible with interfaces
>>
>> type CommonResponse(type E) interface {
>>     GetError() E
>> }
>>
>> type CommonError interface {
>>     GetCode() int32
>> }
>>
>> func IsOK(type R CommonResponse(E), E CommonError)(r R) bool {
>>     switch r.GetError().GetCode() {
>>     case 0, 200, 201:
>>         return true
>>     default:
>>     return false
>>     }
>> }
>>
>> vs
>>
>> constract CommmonResponse(R, E) {
>>     R GetError() E
>>     E GetCode() int32
>> }
>>
>> func IsOK(type R, E CommonResponse)(r R) bool {
>>     switch r.GetError().GetCode() {
>>     case 0, 200, 201:
>>         return true
>>     default:
>>     return false
>>     }
>> }
>>
>> That trickery with commas to express dependcy of types is hard
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/golang-nuts/4e25a228-4c96-44ba-b33a-bbde3460ea2ao%40googlegroups.com
>> <https://groups.google.com/d/msgid/golang-nuts/4e25a228-4c96-44ba-b33a-bbde3460ea2ao%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEkBMfH_NvKTi5yZgaHNuM%3D3nGhUdHvcgogOibS-WdQEga1JSw%40mail.gmail.com.

Reply via email to