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

Remove polymorphic monads #219

Merged
merged 2 commits into from
Aug 7, 2018
Merged

Conversation

elldritch
Copy link
Member

Fixes #210.

@elldritch elldritch requested a review from delikat August 7, 2018 02:28
func NearestVCS(dirname string) (vcsType cli.VCS, vcsDir string, err error) {
vcsDir, err = files.WalkUp(dirname, func(d string) error {
tool, err := vcsIn(d)
func Nearest(dirname string) (VCS, string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 to this and other renames

// containing the directory, or ErrNoNearestVCS if none is found.
func NearestVCS(dirname string) (vcsType cli.VCS, vcsDir string, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the move away from named returns?

Copy link
Member Author

Choose a reason for hiding this comment

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

I just avoid them where possible, because assignment in Go follows unintuitive shadowing rules. I usually only use named returns when returning multiple values of the same type.

Example of weird shadowing:

func Foo() (bar string) {
	bar, err := Baz() // This is a _different_ bar, shadowing the original
	return            // Implicitly returns `bar = ""`, the string type's zero value
}

Copy link
Contributor

@delikat delikat left a comment

Choose a reason for hiding this comment

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

Nice! This is so much cleaner and DRYer. lgtm 👍

@elldritch elldritch force-pushed the refactor/210-monomorphic-monads branch from ab5c1cd to d638517 Compare August 7, 2018 18:24
@elldritch elldritch merged commit 83fae0f into master Aug 7, 2018
@elldritch elldritch deleted the refactor/210-monomorphic-monads branch August 7, 2018 21:21
meghfossa pushed a commit that referenced this pull request Nov 12, 2021
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