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

Make >>- operator precedence compatible with other frameworks. #49

Merged
merged 1 commit into from
May 24, 2015
Merged

Make >>- operator precedence compatible with other frameworks. #49

merged 1 commit into from
May 24, 2015

Conversation

kareman
Copy link
Contributor

@kareman kareman commented May 23, 2015

The Runes framework has changed its >>- operator precedence to be more like Haskells, see thoughtbot/Runes#30. This means you can't use Runes, Result and >>- in the same Swift file because the compiler complains about ambiguous operator precedence definitions. I ran into this problem with a version of Gordon Fontenots implementation of <*> and <^> for Result.

robrix/Either#28 and robrix/Madness#86 have also made the same change.

This also makes it more similar to Haskell, see thoughtbot/Runes#30.
These frameworks have made this change:

- thoughtbot/Runes@d3a7d63
- robrix/Either#28
- robrix/Madness#86
kareman added a commit to kareman/FootlessParser that referenced this pull request May 23, 2015
Result is once again an enum. Also this removes 3 frameworks that are no longer needed ("id" was previously in Prelude).
Runes has new precedence for operators (thoughtbot/Runes#30):

	infix operator <^> { associativity left precedence 130 }
	infix operator <*> { associativity left precedence 130 }
	infix operator >>- { associativity left precedence 100 }
	infix operator -<< { associativity right precedence 100 }

This means Result must use the same precedence for >>- .  Hopefully this pull request will be accepted: antitypical/Result#49 . In the meantime we have to use my own fork https://github.com/kareman/Result/tree/flatmap-operator-precedence.
@robrix
Copy link
Contributor

robrix commented May 24, 2015

👍

robrix added a commit that referenced this pull request May 24, 2015
Make >>- operator precedence compatible with other frameworks.
@robrix robrix merged commit 81b1896 into antitypical:master May 24, 2015
@kareman kareman deleted the flatmap-operator-precedence branch May 26, 2015 09:27
@kareman
Copy link
Contributor Author

kareman commented May 26, 2015

Btw, do you know if the comment above the changed line is still correct?

            // Higher precedence than function application, but lower than function composition.

@gfontenot
Copy link
Member

Prelude is defining function application at 95, and composition at 170, so that comment still holds true.

kareman added a commit to kareman/FootlessParser that referenced this pull request May 26, 2015
Switch back to using https://github.com/antitypical/Result as pull request antitypical/Result#49 was accepted and it now is using precedence 100 for the >>- operator.
@kareman kareman restored the flatmap-operator-precedence branch June 2, 2015 18:02
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.

None yet

3 participants