3 ms·
This makes it seem like modules are strictly inferior, if you can't assign names to common requirements.
by svrb 6y ago
This makes it seem like modules are strictly inferior, if you can't assign names to common requirements.
- kdkeyser 6y agoI don't see how you come to that conclusion. Assigning a name to a requirement (~ an interface) is the most simple usage of the module. E.g. to define something like IComparable, you could write: module type Comparable = sig type t val compare : t -> t -> int end
- ufo 6y agoYou can still give a name to the interface. However, interfaces apply to modules, not to types. In Ocaml you'd say "this module implements the Comparable interface" while in an OO languague you'd say "this type is a subtype of Comparable". Sorry for the confusion.
- svrb 6y agoAh, thanks for the clarification.