2 ms·
This post doesn't seem like a criticism of FP so much as the module system in Haskell, ML has a more powerful module system. On r/haskell, user mutantmell gave
by enugu 2y ago
This post doesn't seem like a criticism of FP so much as the module system in Haskell, ML has a more powerful module system.
On r/haskell, user mutantmell gave a implementation of the code (assuming such a module system) closely following the Dart code given in the original post.
https://gist.github.com/mutantmell/c3e53c27b7645a9abad7ef132fd5bddf https://gist.github.com/mutantmell/c3e53c27b7645a9abad7ef132...
https://www.reddit.com/r/haskell/comments/1fzy3fa/oop_is_not_that_bad_actually/lr4xnsx/ https://www.reddit.com/r/haskell/comments/1fzy3fa/oop_is_not...
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...
>(Java-style) OOP offers a solution for this: you can code against the abstract type for code that doesn't care about the particular instance, and you can use instance-specific methods for code that does. Importantly, you can mix and match this single instance of the datatype in both cases, which I believe to be a superior coding experience than having two separate datatypes used in separate parts of your code.
>"Proper" module systems (ocaml, backpack, etc) offer a better solution that either of these: when you write a module that depends on a signature, you can only use things provided by that signature. When you import that module (and therefore provide a concrete instance of the signature), the types become fully specified and you can freely mix (Logger -> Logger) and (SpecificLogger -> SpecificLogger) functions. This has the advantage of working very well with immutable, strongly-typed functional code, unlike the OOP solutions.
>This is in essence the same argument for row-polymorphism, just for modules rather than records. It can be better to code against abstract structure in part of your code, and a particular concrete instance that adheres to that structure in other parts.