-
Notifications
You must be signed in to change notification settings - Fork 341
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
update functors.md with minor tweaks #2984
base: main
Are you sure you want to change the base?
Conversation
b62c04e
to
4c84091
Compare
4c84091
to
d057ce0
Compare
In the example above, `t` from `with type` takes precedence over the local `t`, which only has a local scope. Don't shadow names too often because it makes the code harder to understand. | ||
In the example above, `t` from `with type` takes precedence over the local `t`, which only has a local scope. | ||
|
||
**Warning**: Don't shadow names too often because it makes the code harder to understand. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jakubsvec001. This is nice, only minor edits proposed.
|
||
**Note**: An OCaml interface file (`.mli`) must be a module, not a functor. Functors must be embedded inside modules. Therefore, it is customary to call them `Make`. | ||
**Note**: While an OCaml interface file (`.mli`) is a module, an interface file is not allowed to be a functor. Functors must be embedded inside modules. Therefore, it is customary to call them `Make`. <!-- I find this confusing; is "Make" a synononym for OCaml functors? -Jakub --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
**Note**: While an OCaml interface file (`.mli`) is a module, an interface file is not allowed to be a functor. Functors must be embedded inside modules. Therefore, it is customary to call them `Make`. <!-- I find this confusing; is "Make" a synononym for OCaml functors? -Jakub --> | |
**Note**: An OCaml file (`.ml`) defines a module, not a functor. Functors must be embedded inside modules. It is customary to call the functor `Make`. This allows writing `module IntSet = Set.Make(Int)`. |
You're right; the initial text was confusing and wrong. Thanks for pointing this. Do you think the code module IntSet = Set.Make(Int)
needs to be explained?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not a bad idea.
@@ -330,7 +330,7 @@ Check the program's behaviour using `opam exec -- dune exec funkt < dune`. | |||
|
|||
[Dependency injection](https://en.wikipedia.org/wiki/Dependency_injection) is a way to parametrise over a dependency. | |||
|
|||
Here is a refactoring of the module `IterPrint` to use this technique: | |||
Here is a refactoring of the module `IterPrint` to use dependency injection: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the repetition here?
Small tweaks for clarity.
This pull request has an embedded question about the meaning of the
line 354:
Note: While an OCaml interface file (
.mli
) is a module, an interface file is not allowed to be a functor. Functors must be embedded inside modules. Therefore, it is customary to call themMake
.