3 ms·
The overtyping seems not about not about static vs dynamic but about nominal typing(functions based on the abstract type) vs structural typing/row-polymorphism
by enugu 2y ago
The overtyping seems not about not about static vs dynamic but about nominal typing(functions based on the abstract type) vs structural typing/row-polymorphism (functions based on specific fields). Go seems to have structural typing, though less used. Do you have the same problem with overtyping while using structural typing?
There was a very similar complaint [1] ("OOP is not that bad") favorably comparing the flexibility of OOP classes in Dart vs typeclasses in Haskell. But as pointed out by /u/mutantmell [2], this is again about lack of 'structural typing' at the level of modules with exported names playing the role of fields. First class modules in functional languages like ML (backpack proposal in Haskell or units in Racket) allow extensible interfaces and are even more expressive than classes in most usual OOP languages. First-class modules are equivalent to first-class classes [3] ie. a class expression is a value, so a mixin is a regular function which takes a class and returns a class. Both are present in Racket.
[1] https://news.ycombinator.com/item?id=41901577 https://news.ycombinator.com/item?id=41901577
[2] https://www.reddit.com/r/haskell/comments/1fzy3fa/oop_is_not_that_bad_actually/lrbgq5d/ https://www.reddit.com/r/haskell/comments/1fzy3fa/oop_is_not...
[3] https://docs.racket-lang.org/guide/unit_versus_module.html https://docs.racket-lang.org/guide/unit_versus_module.html