3 ms·
> The extreme-radical FP view is to ask why we need keywords like private at all. I'd say this isn't quite true. FP is full of sophisticated ways to hide infor
by tel 12y ago
> The extreme-radical FP view is to ask why we need keywords like private at all.
I'd say this isn't quite true. FP is full of sophisticated ways to hide information. Done correctly it is a giant boon to composability—often done under the name "modularity".
The core of this function resides in type quantification—existential or universal. Any polymorphic type system will thus have a small amount of this. In particular, the fact that a function is parametric in a type is exactly an expression of the fact that a function remains ignorant to all details of the type actually chosen:
id :: a -> a -- a function with this type cannot examine its argument
id x = x
More tangibly, ML-family languages (but not quite F#, I don't think) have the ability to create abstract types by exporting module signatures which are ignorant to the actual type embodied in the struct. Again, this is a powerful technique for increasing composability.
The core idea in each case is that when you build interfaces which demand exactly and only what they truly need from their impementers then you allow the maximal variety of implementers possible. You also allow the implementer to be exchanged---your use of this interface thus composes in more contexts.
- JamesSwift 12y agoThis is exactly what I was trying to say in my comment regarding composability/orthogonality in FP. You've presented the point much clearer than I did : )