-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
elaborate more on functor comparing to higher order function #2607
Comments
Hi @geohuz, thanks for your careful reading and feedback; this is helpful.
Yes, this sentence isn't great.
You are right.
Yes, you got it right. This is what a functor allows, not having to pass the comparison function (for instance) at each function call. “Boilerplate” isn't a great term, but client code is somehow simpler/shorter as the comparison function isn't passed at each call to a functor-hosted function. And yes, this is one of the main rationales for using functors. Do you have suggestions on how to improve this text? |
Hi @cuihtlauac, thanks for your prompt reply! My suggestion is to give an example to explain the idea, so this can happen in other functors like Set... |
Do you want to propose a PR with with? It would be easier to discuss the matter with the actual example. An we love contributions :-) |
In the ocaml docmentation chapter functor, when I read this paragraph:
I couldn't image how the higher order function way can "add a lot of boilerplate code", as a new ocaml user this can be confusing. I've tried to look at source code like Map module, I found a funcion that calling compare like add:
So for this case, the
add
function if without functor, then we have to define it like this:I'm not sure if I understand it correctly, but I guess this should be one of the rational of using functor instead of higher order function. I wish this can be elaborated in a crystal clear way because that is the point of having functor in Ocaml?
The text was updated successfully, but these errors were encountered: