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

either: add S.eitherToMaybe #215

Merged
merged 1 commit into from
May 18, 2016
Merged

either: add S.eitherToMaybe #215

merged 1 commit into from
May 18, 2016

Conversation

davidchambers
Copy link
Member

Closes #203

//# maybeToEither :: a -> Maybe b -> Either a b
//.
//. Takes a value of any type and a Maybe, and returns an Either.
//. If the second argument is a Nothing, a Left containing the first
Copy link
Member

Choose a reason for hiding this comment

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

Might not be worth it for the sake of consistency throughout the docs, but when the types of arguments are different, it is easier for me to follow if the type is referenced rather than the argument position, ie

If the Maybe is a Nothing, a Left containing the first argument is returned.

Obviously since is a Nothing immediately follows second argument, I should know it is a Maybe I'm dealing with, but when I hit "second argument" I always pause.. think "second argument..??" jump back to the signature.. then continue on :)

Copy link
Member Author

Choose a reason for hiding this comment

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

"The Maybe" is slightly less precise than "the second argument", since the first argument could also be a Maybe, but I'm happy to make your suggested change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Another possibility:

Converts a Maybe to an Either. A Nothing becomes a Left (containing the first argument); a Just becomes a Right.

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member Author

Choose a reason for hiding this comment

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

@davidchambers davidchambers force-pushed the dc-either branch 2 times, most recently from c66ba2a to 57440b3 Compare May 9, 2016 05:40
@davidchambers davidchambers merged commit 4aa1b02 into master May 18, 2016
@davidchambers davidchambers deleted the dc-either branch May 18, 2016 01:07
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