-
Notifications
You must be signed in to change notification settings - Fork 349
extrapolation on Option.bind example using Option.map and Option.join #2987
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
Conversation
I'd like this remark to remain in the tutorial on options:
This outlines the view many share in the community. OCaml teaching materials shouldn't give the impression that category theory is a requirement or useful for learning or using OCaml. I believe it is the other way around. Once comfortable with With that in mind, I believe we're missing a tutorial showing monad “fun facts” such as: bind ≅ map ∧ join
extend ≅ map ∧ dupe
app ≅ map ∧ combine
bind -> app -> map
extend -> app -> map
(* with *)
val join : 'a t t -> 'a t
val dupe : 'a t -> 'a t t
val map : ('a -> 'b) -> 'a t -> 'b t
val app : ('a -> 'b) t -> 'a t -> 'b t
val bind : ('a -> 'b t) -> 'a t -> 'b t
val extend : ('a t -> 'b) -> 'a t -> 'b t
val combine : 'a t -> 'b t -> ('a * 'b) t But again, this is merely about showing what are the possible implementation paths. In some sense, it would be a refactoring tutorial. I wonder if it would also make sense to cover distributivity of pairs other So many things to explain! |
P.S. To create a new tutorial, the markdown file needs a Yaml header. That's why the tests are failing on this PR. |
I meant for this pull request to be ephemeral, with the content eventually going into the Option lesson. I didn't want to pollute the other pull request with this longer version, and the other pull request removed the interesting passage on using map and join to define bind. If these two pull requests are combined into one document, the lesson on Option will contain the passage mentioning that there are in fact monads. If instead you envision these being two separate lessons, I can move the passage on Options being monads into the primary lesson and mention this document as a continuation of the topic. QUESTION: How would you like to handle these two pull requests? I can merge the documents or make them separate articles. In the latter case, I can add the passage on monads back into the first article.
I really like this idea. I'll add "Monad Fun Facts" to the list.
As someone consuming the material from the outside, my impression is that the present material handles both predispositions quite well. Keeping CT in the background and only mentioning it in passing is very effective at peeling back the curtain and showing the possibilities without making it a prerequisite. It makes sense that OCaml's community would want to avoid suggesting CT is a prerequisite. |
In retrospect, the last section Bind and Option isn't that great. We should first have a short presentation on In the last section we make the comparison between This should remain short. What do you think? |
An updated version of this content has been added to another pull request 2986 |
This is 1 of 2 pull requests on the option.md tutorial.
I broke these into two parts. I don't intend for part 2's suggestions to be pulled into the repo since they are currently in a separate file for your consideration. There is probably a better way for me to structure such a pair of pull requests such that they can be considered separately and am open to suggestions for the future. My priority was to keep them from stepping on each other during a potential merge.
Part 1:
Part one has some minor tweaks and additional examples. This includes an updated "## Conclusion" to be more encompassing of the lesson as a whole. The deleted "## Conclusion" is included in part 2.
Part 1 can be found here: #2986
Part 2:
Part two is an extrapolation on the Option.bind implementation example using Option.map and Option.join. I found this example fun to consider but thought it warranted a longer treatment since it is not immediately clear how Option.map and Option.join chain together.