Skip to content

Show Either's "do notation" similarity to nested if-then-else statement #52

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 2 commits into from
Oct 15, 2020
Merged

Conversation

JordanMartinez
Copy link
Contributor

No description provided.

@hdgarrood
Copy link
Contributor

I think this is probably more suitable for the Bind (Either e) instance. I would say that it's really the Bind instance which enables do notation, as for do notation all you really need is bind. Personally, I think the Monad instance docs should be left at "The Monad instance guarantees that there are both Applicative and Bind instances for Either, and the rest of these docs should be on the Bind instance.

@hdgarrood
Copy link
Contributor

I agree that a more intuitive explanation of what the Bind instance does would be good, but I'm not sure pseudocode is the best way of achieving that; I think prose would probably be preferable.

@hdgarrood
Copy link
Contributor

The reason that I prefer prose over pseudocode is mostly that not everyone is that familiar with whatever language your pseudocode is based on, and even if they were, they might not be able to work out what e.g. unwrapRight or wrapIntoRight are supposed to be doing, or might get hung up on the fact that unwrapRight doesn't have parens to indicate that it's a function. In general I think prose explanations are less likely to accidentally introduce this kind of inaccessibility where you make assumptions about what the reader knows, or how they are likely to interpret something.

@JordanMartinez
Copy link
Contributor Author

Not using pseudo code makes sense. However, I'm not sure how to write that without it being just as confusing. I feel like a visual of some sorts would explain this much better. Is it possible to include images in documentation?

@JordanMartinez
Copy link
Contributor Author

JordanMartinez commented Jun 4, 2020

Also, I explained how the Array monad works in purescript-prelude via purescript/purescript-prelude#217. It's currently on the Monad instance rather than the Bind instance. So, I should update it there to be consistent with what we do here. Edit: that's been done.

@JordanMartinez
Copy link
Contributor Author

Rather than using pseudo-code, I explained it using regular PureScript.

I also moved the explanation to the Bind instance.

@JordanMartinez
Copy link
Contributor Author

I had to force-push this because CI was not pulling in the v0.14.0-rc3 binary

@JordanMartinez
Copy link
Contributor Author

CI now builds. Harry, this is the same approach you previously approved regarding Maybe's do notation documentation.

Copy link
Contributor

@hdgarrood hdgarrood left a comment

Choose a reason for hiding this comment

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

Looks great!

@JordanMartinez JordanMartinez merged commit 69959e0 into purescript:master Oct 15, 2020
@JordanMartinez JordanMartinez deleted the addDocs branch October 15, 2020 01:44
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.

2 participants