4 ms·
The use of an Interface type in Go is a good sign that either the data or the logic flow isn't optimized for static analysis and optimizations. The most common
by mjevans 6y ago
The use of an Interface type in Go is a good sign that either the data or the logic flow isn't optimized for static analysis and optimizations.
The most common case I happen to have run across is the result of parsing data or configuration files; situations where there might be structure, but all of it is optional.
PS: Your "algebraic data types / sum types" sounds very much like interface composition, a ReaderWriter ( E.G. https://golang.org/pkg/io/#ReadWriter https://golang.org/pkg/io/#ReadWriter ) for example composes interface types.
- c-cube 6y agoThis is a product, not a sum. It's just a pair of Reader and Writer. Sum types would also give you the ability to say "reader or writer" and use pattern matching to find out which one you were given. C-like languages traditionally give only the 'product' half of types (C also gives union but they're super low level, and Go just eschewed them). A _modern_ language would give both products and sums.
- pkolaczk 6y agoInterface composition is product of types, not sum.