2 ms·
Yes, you need to add new functions. You cannot redefine "+" to work a custom vector type. Similarly, you cannot have a "print" function that works for all sort
by atombender 7y ago
Yes, you need to add new functions. You cannot redefine "+" to work a custom vector type.
Similarly, you cannot have a "print" function that works for all sorts of types. OCaml has print_string, print_int, and so on.
OCaml does have parametric polymorphism ("generics"). You can write functions which support generic parameters. And you can use modules as "functors" to sort of package up types in a similar way as Haskell typeclasses (e.g. see [1]).
[1] https://stackoverflow.com/questions/14934242/whats-the-closest-thing-to-haskells-typeclasses-in-ocaml https://stackoverflow.com/questions/14934242/whats-the-close...