这是indexloc提供的服务,不要输入任何密码
Skip to content

[Docs] Rename Opt to Maybe in guide #1340

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

Merged
merged 3 commits into from
Nov 1, 2023
Merged

Conversation

micahcantor
Copy link
Contributor

@micahcantor micahcantor commented Nov 1, 2023

When I was learning Typed Racket, I was confused by this section of the guide, which gives an example of defining a polymorphic data type. The example used is an optional type called Opt, defined analogously to Maybe in Haskell. Personally, this example was confusing to me since I then thought the the Option type provided by the standard library was defined in the same way. However, that (Option t) type is actually defined as either t or #f, which aligns better with Racket conventions.

To avoid this confusion, and since Maybe from Haskell is already mentioned here, I recommend changing the name of Opt to Maybe in this example. I also changed type parameter names to be upper case in this example, for consistency with the rest of the language.

It also may be helpful to add a note afterward explaining that in a "real" program, for consistency the user should probably use Option rather than their own Maybe type, but maybe that's unnecessary, so I left it out here.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Resyntax analyzed 0 files in this pull request and found no issues.

@shhyou
Copy link
Contributor

shhyou commented Nov 1, 2023

I think the current name is also a common one (e.g. 'a option = NONE | SOME of 'a from SML and 'a option = None | Some of 'a from OCaml). Perhaps the guide could actually refer to SML/OCaml instead of Haskell.

Disambiguating Opt from the built-in Option does sound like a good idea.

@micahcantor
Copy link
Contributor Author

I agree, it's less that I think the guide needs to adopt Haskell's terminology, and more that as a newcomer to Typed Racket (but having experience with Haskell/OCaml) the guide was confusing since I didn't know if I should use Option as defined in the standard library or Opt as defined here.

@sorawee
Copy link
Contributor

sorawee commented Nov 1, 2023

I think we all agree that Opt is not a great name, because it's too similar to Option, which is a built-in type (that does something slightly different).

So let's use the name Maybe, and since you already renamed None to Nothing, maybe (see what I did here?) you want to rename Some to Just too?

@micahcantor
Copy link
Contributor Author

maybe (see what I did here?) you want to rename Some to Just too?

Oops, it's been a little while since I used Haskell instead of OCaml, I did mean that!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Resyntax analyzed 0 files in this pull request and found no issues.

@sorawee
Copy link
Contributor

sorawee commented Nov 1, 2023

Thanks!

@sorawee sorawee merged commit 8a6c15d into racket:master Nov 1, 2023
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