|
|
|
|
|
by higherkinded
2511 days ago
|
|
It's "typeclass", not "interface". Though it works similar and is, in fact, just a way to define a constraint. As of your described way of desugaring the contract, looks way too cluttered. It's exactly the reason why Reader and ReaderT exist in Haskell. Even though the proposal's contract syntax doesn't look very beautiful, it's still drastically better than keeping track of drilled structs of functions, the latter will become a mess really really fast, so having a way to conveniently constraint the accepted types while having a full-blown parametric polymorphism is essential for a modern language. Not sure exactly why anyone would be against that. |
|
The whole point is to implement the bare bones of a parametric polymorphic system without constraining further development of the language. Additionally, it discourages complexity and requires explicitness, two goals of Go.
As far as my description of desugaring the contract, that is literally how Haskell implements typeclasses.