Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jakubsvec001
Copy link
Contributor

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 them Make.

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!

Copy link
Collaborator

@cuihtlauac cuihtlauac left a 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 -->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**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?

Copy link
Contributor

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the repetition here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants