4 ms·
> when I would make a class in C++/C#/Java, I make a module in Haskell. This. Group you code logically, expose only what's needed. This also gives the FPer a l
by cies 9y ago
> when I would make a class in C++/C#/Java, I make a module in Haskell.
This. Group you code logically, expose only what's needed. This also gives the FPer a large part of the "encapsulation" and "group by responsibility" advantages that are often mentioned as pros of OO. Without going down the "implicit state sharing" path.
- catnaroek 9y agoEncapsulation works even better with modules than with objects: (0) Modules may expose n-ary operations on abstract types for n > 1. (1) Modules may have multiple interrelated abstract type components, i.e., what Stepanov calls “multisorted algebras”. Furthermore, if you are willing to use an impure language (like ML or Scala), modules can be just as stateful as objects if you deem it necessary.