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

Fix misleading example of open object types #768

Open
wants to merge 1 commit into
base: source
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions docs/object.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type car('a) = {
} as 'a;
```

Two dots, also called an elision, indicate that this is an "open" object type, and therefore can also contain other values and methods. An open object is also polymorphic and therefore requires a parameter.
Two dots, also called an elision, indicate that this is an "open" object type, and therefore can also contain other values and methods. An open object is also polymorphic and therefore requires a parameter. This parameter refers to the complete type of the object, including those other values and methods.

Comment on lines +29 to 30
Copy link
Member

Choose a reason for hiding this comment

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

Agree here with you that this isn't right, since open object is the form of structural typing.

I'm not sure if this entire paragraph make sense after your addition thought. Since you refer to the as 'a without being very explicit.

Copy link
Author

Choose a reason for hiding this comment

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

Just checking: By "Agree with you that this isn't right", are you referring to the old code example, rather than the part that is quoted here?

I don't see how the sentence I added would cause the paragraph to make less sense than it did previously. It already referred to the 'a when it said "and therefore requires a parameter".

### Creation

Expand Down Expand Up @@ -77,7 +77,9 @@ type tesla('a) = {
drive: int => int
} as 'a;

let obj: tesla({. drive: int => int, doYouWant: unit => bool}) = {
let driveInterstate = (t: tesla('a)) => t#drive(60);

let obj: {. drive: int => int, doYouWant: unit => bool} = {
val hasEnvy = ref(false);
pub drive = (speed) => {
this#enableEnvy(true);
Expand All @@ -91,5 +93,6 @@ let obj: tesla({. drive: int => int, doYouWant: unit => bool}) = {
You can use the above object like so:

```reason
driveInterstate(obj);
obj#doYouWant();
```